I'm doing this exact example from the phonegap docs.
<!DOCTYPE HTML>
<html>
<head>
<title>getPreferredLanguage Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
function checkLanguage() {
navigator.globalization.getPreferredLanguage(
function (language) {alert('language: ' + language.value + '\n');},
function () {alert('Error getting language\n');}
);
}
</script>
</head>
<body>
<button onclick="checkLanguage()">Click for language</button>
</body>
</html>
When I click the button I want it to return the language I'm using on my phone.
It works good if I run it through the PhoneGap app, while connected to the local server on my computer (phonegap serve) however it won't work after making the .apk and installing it on my phone. What am I missing?
edit: here's the config.xml
http://pastebin.com/t6fx3jRD
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.phonegap.helloworld" version="1.0.0"
xmlns="http://www.w3.org/ns/widgets"
xmlns:gap="http://phonegap.com/ns/1.0">
<name>hi bi</name>
<description>
sample stuff
</description>
<author email="support#phonegap.com" href="http://phonegap.com">
PhoneGap Team
</author>
<content src="index.html" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<preference name="phonegap-version" value="3.3.0" />
<preference name="permissions" value="none" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="false" />
<preference name="ios-statusbarstyle" value="black-opaque" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="auto-hide-splash-screen" value="true" />
<preference name="android-installLocation" value="auto" />
<icon src="icon.png" />
</widget>
I don't see any obvious problems, but there are five things that should be resolved.
you need to post your config.xml to this forum. If you delete that pastebin file, others will not be able to benefit from this. (If we can get it to work.)
you are using the generic file, which is not a bad thing, except the large file makes it more difficult to spot a problem.
you did NOT use <preference name="phonegap-version" value="X.X.X" />, which is not required. But since you do not, then by default you get the latest version (the bleeding edge) of the phonegap. (This might get you leading edge bugs which would be difficult to debug -- without asking for lots of help.)
Since you are using the latest version of Phonegap, and not 3.3.0, then you should reference leading edge - which does not have an full example.
Since you did NOT say what your target platform is, then perhaps you should look at the Bug List
Lastly, you might consider using an earlier version, say <preference name="phonegap-version" value="3.3.0" />, and try you build again. Oh and RTFM.
Best of Luck, Jesse
Related
I tried to reinstall iis on my windows 10 system through Control Panel\Programs and Features\ Turn Windows features on or off but after uninstalling it there is a problem with installing iis again.
Here are screenshots with all errors I'm facing at the moment:
In folder Windows/System32/inetsrv/config I recreated file named ApplicationHost.config
here is the configuration:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<system.applicationHost>
<applicationPools>
<add name="DefaultAppPool" />
<applicationPoolDefaults>
<processModel identityType="NetworkService" />
</applicationPoolDefaults>
</applicationPools>
<customMetadata />
<listenerAdapters>
<add name="http" />
</listenerAdapters>
<log>
<centralBinaryLogFile enabled="true" directory="%SystemDrive%\inetpub\logs\LogFiles" />
<centralW3CLogFile enabled="true" directory="%SystemDrive%\inetpub\logs\LogFiles" />
</log>
<sites>
<site name="Default Web Site" id="1">
<application path="/">
<virtualDirectory path="/" physicalPath="%SystemDrive%\inetpub\wwwroot" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%SystemDrive%\inetpub\logs\LogFiles" />
<traceFailedRequestsLogging directory="%SystemDrive%\inetpub\logs\FailedReqLogFiles" />
</siteDefaults>
<applicationDefaults applicationPool="DefaultAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
<webLimits />
</system.applicationHost>
</configuration>
Does anyone had something like that before me and was able to run IIS again without reinstalling entire system from scratch?
If any information needed please do not hasitate to ask in comment section.
Thanks in advance :)
Thanks to #LexLi and links provided by him i was able to find out what caused the issue.
Main Link
Second one
And last which point the way to uninstall Windows Process Activation Service in Windows 10 pro not server one
Just to be sure I uninstalled:
Internet Information Services Hostable Web Core
I hope this answer would help someone in future.
Thanks again #LexLi for assistant.
Cheers!
I was trying to use to run specific nodejs scripts per pratform.
In the docs it says it is possible set a hook per platform:
https://cordova.apache.org/docs/en/edge/guide_appdev_hooks_index.md.html
If i put the hooks in config.xml outsite of the platforms tags, the scripts will be called:
<hook type="before_platform_add" src="HookInstallPluginsWP8.js" />
<hook type="before_platform_add" src="HookInstallPluginsIOS.js" />
But if I put it inside a tag it does not run:
<platform name="wp8">
<preference name="fullscreen" value="true"/>
<hook type="before_platform_add" src="HookInstallPluginsWP8.js" />
</platform>
<platform name="ios">
<preference name="fullscreen" value="true"/>
<hook type="before_platform_add" src="HookInstallPluginsIOS.js" />
</platform>
What I'm doing wrong?
This doesn't seem to be supported until Cordova 5.x. Are you sure you are running the latest Cordova?
npm install -g cordova
I think I found the reason why this was happening.
Today I tried to add <icons> and <splash> images to my project and I faced the same situation. The icons and splash were not added if inside a platform tag.
In my case this was happening because inside a <platform> tag, it only could exist one type of tag.
For example:
<platform name="android">
<preference name="fullscreen" value="true"/>
<hook type="before_platform_add" src="HookInstallPluginsAndroid.js" />
<icon src="res/icons/android/icon-36-ldpi.png density="ldpi" />
</platform>
In this case the hook and the icon will be ignored.
I have to add different <platform> nodes:
<platform name="android">
<preference name="fullscreen" value="true"/>
</platform>
<platform name="android">
<icon src="res/icons/android/icon-36-ldpi.png density="ldpi" />
</platform>
<platform name="android">
<hook type="before_platform_add" src="HookInstallPluginsAndroid.js" />
</platform>
Is this a documented case? I did not found anything on cordova docs... maybe it's just a bogus situation?
I am trying to hide the console when running the Haxe application.
I am using FlashDevelop to compile Haxe into hxcpp, and this is my project.xml
<?xml version="1.0" encoding="utf-8"?>
<project>
<!-- metadata, make sure 'package' is at least 3 segments (ie. com.mycompany.myproject) -->
<meta title="haxeGame" package="haxeGame" version="1.0.0" company="xiggie" />
<!-- output -->
<app main="Main" file="haxeGame" path="bin" />
<window width="800" height="480" fps="60" background="0x000000" orientation="landscape" resizable="false" borderless="true" />
<window vsync="true" antialiasing="6" />
<!-- classpath, haxe libs -->
<classpath name="src" />
<haxelib name="openfl" />
<haxelib name="actuate" />
<!-- assets -->
<icon path="assets/texture.jpg" />
<assets path="assets" rename="assets" />
<!-- optimize output
<haxeflag name="-dce full" /> -->
<!-- Windows app: hide console -->
<setenv name="no_console" value="1" />
<flag value="subsystem:windows" />
</project>
I have tried all of these:
<haxeflag name="-D no_console" />
<haxedef name="no_console" />
<setenv name="no_console" value="1" />
Is it actually possible to remove the console from the release app?
The console should be hidden by default. To make it appear one needs to add
<setenv name="SHOW_CONSOLE" />
However, when using mingw instead of msvc as compiler, the toolchain configuration that comes with hxcpp currently does not pass the flag to the linker that avoids the creation of a console window.
To work around this, search for the mingw-toolchain.xml in your haxe installation and add the -mwindows flag to the linker configuration.
I created a pull request for this https://github.com/HaxeFoundation/hxcpp/pull/286
I want to copy files over to a server but before i do this i would like to include the latest msi file that i generate.
I noticed that the ItemGroup and Item have a Condition attribute but i do not know how to utilize this to include the latest file.
So far this is my setup:
<Target Name="AfterBuild">
<ItemGroup>
<Installers Include="\\SERVERNAME\BuildOutput\ProductStream\**\Installers\Customer\Installer.msi"/>
</ItemGroup>
<Message Text="FirstItem: %(Installers.Filename)" />
<Message Text="FirstItem: %(Installers.FullPath)" />
The output of this are two files:
e.g
\\Servername\BuildOutput\ProductStream\Installers\ProductStreamV2.1.1202.1402\Installer.msi
\\Servername\BuildOutput\ProductStream\Installers\ProductStreamV2.1.1405.1301\Installer.msi
I want to include the 2.1.1405.1301 build in the Item as this is the latest one.
I would appreciate if someone would assist me because i cannot find how to go about doing this from the MSDN blogs.
Thanks,
You could use a custom task for this purpose. It allows you to filter items any way you want. Here I used regular expressions to select the latest installer:
<Target Name="AfterBuild">
<ItemGroup>
<Installers Include="**\Installer.msi"/>
</ItemGroup>
<SelectLatestInstaller Installers="#(Installers)">
<Output TaskParameter="LatestInstaller" ItemName="LatestInstaller" />
</SelectLatestInstaller>
<Message Text="%(LatestInstaller.FullPath)" />
</Target>
<UsingTask TaskName="SelectLatestInstaller"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Installers ParameterType="System.String[]" Required="true" />
<LatestInstaller ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Linq" />
<Using Namespace="System" />
<Using Namespace="System.Linq" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
LatestInstaller = Installers
.OrderByDescending(f => Regex.Match(f, #"\\ProductStreamV(?<version>(\d+.){0,3}\d+)\\").Groups["version"].Value)
.FirstOrDefault();
]]>
</Code>
</Task>
</UsingTask>
PhoneGap version: 2.9
Test device: 3gs with iOS 6.1.3
I'm using the PhoneGap build service provided by Adobe
I want to prevent the whole app from overscrolling. I've read the related questions and added the following to my config.xml
<preference name="DisallowOverscroll" value="true" />
<preference name="UIWebViewBounce" value="false" />
which has no effect.
What am I doing wrong?
Finally found it: it's webviewbounce not UIWebViewBounce
<preference name="webviewbounce" value="false" />
PhoneGap Build will translate this to DisallowOverscroll.
See http://community.phonegap.com/nitobi/topics/2_7_0_webview_bounce_bug for discussion.
I am using PhoneGap version 3.0.0
I had to do two things to get this working:
Firstly:
I had this set in my index.html:
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=medium-dpi" />
Needed to change this to:
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, target-densitydpi=medium-dpi" />
When setting device height, my 100% heights were taking into consideration the status bar.
I then also had to add this line into my config.xml:
<preference name="DisallowOverscroll" value="true" />
Hope this helps,
Ian