- Q1: How do I set app orientation?
If you are using Cordova* 3.X build options (Crosswalk* for Android*, Android*, iOS*, etc.), you can set the orientation under the Projects panel > Select your project > Cordova* 3.X Hybrid Mobile App Settings - Build Settings. Under the Build Settings, you can set the Orientation for your desired mobile platform.
If you are using the Legacy Hybrid Mobile App Platform build options (Android*, iOS* Ad Hoc, etc.), you can set the orientation under the Build tab > Legacy Hybrid Mobile App Platforms Category- <desired_mobile_platform> - Step 2 Assets tab.
[iPad] Create a plugin (directory with one file) that only has a config xml that includes the following:
<config-file target="*-Info.plist" parent="UISupportedInterfaceOrientations~ipad" overwrite="true"><string></string></config-file><config-file target="*-Info.plist" parent="UISupportedInterfaceOrientations~ipad" overwrite="true"><array><string>UIInterfaceOrientationPortrait</string></array></config-file>
Add the plugin on the build settings page.
Alternatively, you can use this plugin: https://github.com/yoik/cordova-yoik-screenorientation. You can import it as a third-party Cordova* plugin using the Cordova* registry notation:
- net.yoik.cordova.plugins.screenorientation (includes latest version at the time of the build)
- net.yoik.cordova.plugins.screenorientation@1.3.2 (specifies a version)
Or, you can reference it directly from the GitHub repo:
- github.com/yoik/cordova-yoik-screenorientation.git
- github.com/yoik/cordova-yoik-screenorientation.git#06b93e6
The second reference provides the git commit referenced here (we do not support pulling from the PhoneGap registry).
- Q2: Is it possible to create a background service using Intel XDK?
Background services require the use of specialized Cordova* plugins that need to be created specifically for your needs. Intel XDK does not support development or debug of plugins, only the use of them as "black boxes" with your HTML5 app. Background services can be accomplished using Java on Android or Objective C on iOS. If a plugin that backgrounds the functions required already exists (for example, this plugin for background geo tracking), Intel XDK’s build system will work with it.
- Q3: How do I send an email from my App?
- You can use the Cordova* email plugin or use web intent - PhoneGap* and Cordova* 3.X.
- Q4: How do you create an offline application?
- You can use the technique described here by creating an offline.appcache file and then setting it up to store the files that are needed to run the program offline. Note that offline applications need to be built using the Cordova* or Legacy Hybrid build options.
- Q5: How do I work with alarms and timed notifications?
- Unfortunately, alarms and notifications are advanced subjects that require a background service. This cannot be implemented in HTML5 and can only be done in native code by using a plugin. Background services require the use of specialized Cordova* plugins that need to be created specifically for your needs. Intel XDK does not support the development or debug of plugins, only the use of them as "black boxes" with your HTML5 app. Background services can be accomplished using Java on Android or Objective C on iOS. If a plugin that backgrounds the functions required already exists (for example, this plugin for background geo tracking) the Intel XDK’s build system will work with it.
- Q6: How do I get a reliable device ID?
- You can use the Phonegap/Cordova* Unique Device ID (UUID) plugin for Android*, iOS* and Windows* Phone 8.
- Q7: How do I implement In-App purchasing in my app?
- There is a Cordova* plugin for this. A tutorial on its implementation can be found here. There is also a sample in Intel XDK called ‘In App Purchase’ which can be downloaded here.
- Q8: How do I install custom fonts on devices?
- Fonts can be considered as an asset that is included with your app, not shared among other apps on the device just like images and CSS files that are private to the app and not shared. It is possible to share some files between apps using, for example, the SD card space on an Android* device. If you include the font files as assets in your application then there is no download time to consider. They are part of your app and already exist on the device after installation.
- Q9: How do I access the device’s file storage?
- You can use HTML5 local storage and this is a good article to get started with. Alternatively, there is a Cordova* file plugin for that.
- Q10: Why isn't AppMobi* push notification services working?
- This seems to be an issue on AppMobi’s end and can only be addressed by them. PushMobi is only available in the "legacy" container. AppMobi* has not developed a Cordova* plugin, so it cannot be used in the Cordova* build containers. Thus, it is not available with the default build system. We recommend that you consider using the Cordova* push notification plugin instead.
- Q11: How do I configure an app to run as a service when it is closed?
- If you want a service to run in the background you'll have to write a service, either by creating a custom plugin or writing a separate service using standard Android* development tools. The Cordova* system does not facilitate writing services.
- Q12: How do I dynamically play videos in my app?
1) Download the Javascript and CSS files from https://github.com/videojs
2) Add them in the HTML5 header.
<config-file target="*-Info.plist" parent="UISupportedInterfaceOrientations~ipad" overwrite="true"><string></string></config-file><config-file target="*-Info.plist" parent="UISupportedInterfaceOrientations~ipad" overwrite="true"><array><string>UIInterfaceOrientationPortrait</string></array></config-file>
3) Add a panel ‘main1’ that will be playing the video. This panel will be launched when the user clicks on the video in the main panel.
<div class=”panel” id=”main1” data-appbuilder-object=”panel” style=””><video id=”example_video_1” class=”video-js vjs-default-skin” controls=”” preload=”auto” width=”200” poster=”camera.png” data-setup=”{}”><source src=”JAIL.mp4” type=”video/mp4”><p class=”vjs-no-js”>To view this video please enable JavaScript*, and consider upgrading to a web browser that <a href=http://videojs.com/html5-video-support/ target=”_blank”>supports HTML5 video</a></p></video><a onclick=”runVid3()” href=”#” class=”button” data-appbuilder-object=”button”>Back</a></div>
4) When the user clicks on the video, the click event sets the ‘src’ attribute of the video element to what the user wants to watch.
Function runVid2(){ Document.getElementsByTagName(“video”)[0].setAttribute(“src”,”appdes.mp4”); $.ui.loadContent(“#main1”,true,false,”pop”); }
5) The ‘main1’ panel opens waiting for the user to click the play button.
Note: The video does not play in the emulator and so you will have to test using a real device. The user also has to stop the video using the video controls. Clicking on the back button results in the video playing in the background.
- Q13: How do I design my Cordova* built Android* app for tablets?
- This page lists a set of guidelines to follow to make your app of tablet quality. If your app fulfills the criteria for tablet app quality, it can be featured in Google* Play's "Designed for tablets" section.
- Q14: How do I resolve icon related issues with Cordova* CLI build system?
Ensure icon sizes are properly specified in the intelxdk.config.additions.xml. For example, if you are targeting iOS 6, you need to manually specify the icons sizes that iOS* 6 uses.
<icon platform="ios" src="images/ios/72x72.icon.png" width="72" height="72" /><icon platform="ios" src="images/ios/57x57.icon.png" width="57" height="57" />
These are not required in the build system and so you will have to include them in the additions file.
For more information on adding build options using intelxdk.config.additions.xml, visit: /en-us/html5/articles/adding-special-build-options-to-your-xdk-cordova-app-with-the-intelxdk-config-additions-xml-file
- Q15: Is there a plugin I can use in my App to share content on social media?
Yes, you can use the PhoneGap Social Sharing plugin for Android*, iOS* and Windows* Phone.
- Q16: Iframe does not load in my app. Is there an alternative?
- Yes, you can use the inAppBrowser plugin instead.
- Q17: Why are intel.xdk.istablet and intel.xdk.isphone not working?
- Those properties are quite old and is based on the legacy AppMobi* system. An alternative is to detect the viewport size instead. You can get the user’s screen size using screen.width and screen.height properties (refer to this article for more information) and control the actual view of the webview by using the viewport meta tag (this page has several examples). You can also look through this forum thread for a detailed discussion on the same.
- Q18: How do I work with the App Security plugin on Intel XDK?
Select the App Security plugin on the plugins list of the Project tab and build your app as a Cordova Hybrid app. Building it as a Legacy Hybrid app has been known to cause issues when compiled and installed on a device.
- Q19: Why does my build fail with Admob plugins? Is there an alternative?
Intel XDK does not support the library project that has been newly introduced in the com.google.playservices@21.0.0 plugin. Admob plugins are dependent on "com.google.playservices", which adds Google* play services jar to project. The "com.google.playservices@19.0.0" is a simple jar file that works quite well but the "com.google.playservices@21.0.0" is using a new feature to include a whole library project. It works if built locally with Cordova CLI, but fails when using Intel XDK.
To keep compatible with Intel XDK, the dependency of admob plugin should be changed to "com.google.playservices@19.0.0".
- Q20: Why does the intel.xdk.camera plugin fail? Is there an alternative?
- There seem to be some general issues with the camera plugin on iOS*. An alternative is to use the Cordova camera plugin, instead and change the version to 0.3.3.
- Q21: How do I resolve Geolocation issues with Cordova?
Give this app a try, it contains lots of useful comments and console log messages. However, use Cordova 0.3.10 version of the geo plugin instead of the Intel XDK geo plugin. Intel XDK buttons on the sample app will not work in a built app because the Intel XDK geo plugin is not included. However, they will partially work in the Emulator and Debug. If you test it on a real device, without the Intel XDK geo plugin selected, you should be able to see what is working and what is not on your device. There is a problem with the Intel XDK geo plugin. It cannot be used in the same build with the Cordova geo plugin. Do not use the Intel XDK geo plugin as it will be discontinued.
Geo fine might not work because of the following reasons:
- Your device does not have a GPS chip
- It is taking a long time to get a GPS lock (if you are indoors)
- The GPS on your device has been disabled in the settings
Geo coarse is the safest bet to quickly get an initial reading. It will get a reading based on a variety of inputs, but is usually not as accurate as geo fine but generally accurate enough to know what town you are located in and your approximate location in that town. Geo coarse will also prime the geo cache so there is something to read when you try to get a geo fine reading. Ensure your code can handle situations where you might not be getting any geo data as there is no guarantee you'll be able to get a geo fine reading at all or in a reasonable period of time. Success with geo fine is highly dependent on a lot of parameters that are typically outside of your control.
- Q22: Is there an equivalent Cordova* plugin for intel.xdk.player.playPodcast? If so, how can I use it?
Yes, there is and you can find the one that best fits the bill from the Cordova* plugin registry.
To make this work you will need to do the following:
- Detect your platform (you can use uaparser.js or you can do it yourself by inspecting the user agent string)
- Include the plugin only on the Android* platform and use <video> on iOS*.
- Create conditional code to do what is appropriate for the platform detected
You can force a plugin to be part of an Android* build by adding it manually into the additions file. To see what the basic directives are to include a plugin manually:
- Include it using the "import plugin" dialog, perform a build and inspect the resulting intelxdk.config.android.xml file.
- Then remove it from your Project tab settings, copy the directive from that config file and paste it into the intelxdk.config.additions.xml file. Prefix that directive with <!-- +Android* -->.
More information is available here and this is what an additions file can look like:
<preference name="debuggable" value="true" /><preference name="StatusBarOverlaysWebView" value="false" /><preference name="StatusBarBackgroundColor" value="#000000" /><preference name="StatusBarStyle" value="lightcontent" /><!-- -iOS* --><intelxdk:plugin intelxdk:value="nl.nielsad.cordova.wifiscanner" /><!-- -Windows*8 --><intelxdk:plugin intelxdk:value="nl.nielsad.cordova.wifiscanner" /><!-- -Windows*8 --><intelxdk:plugin intelxdk:value="org.apache.cordova.statusbar" /><!-- -Windows*8 --><intelxdk:plugin intelxdk:value="https://github.com/EddyVerbruggen/Flashlight-PhoneGap-Plugin" />
This sample forces a plugin included with the "import plugin" dialog to be excluded from the platforms shown. You can include it only in the Android* platform by using conditional code and one or more appropriate plugins.
- Q23: How do I display a webpage in my app without leaving my app?
The most effective way to do so is by using inAppBrowser.
- Q24: Does Cordova* media have callbacks in the emulator?
While Cordova* media objects have proper callbacks when using the debug tab on a device, the emulator doesn't report state changes back to the Media object. This functionality has not been implemented yet. Under emulation, the Media object is implemented by creating an <audio> tag in the program under test. The <audio> tag emits a bunch of events, and these could be captured and turned into status callbacks on the Media object.
- Q25: Why does the Cordova version not match between the Projects tab Build Settings, Emulate tab, App Preview and my built app?
This is due to the difficulty in keeping different components in sync and is compounded by the version convention that the Cordova project uses to distinguish build tools (the CLI version) from frameworks (the Cordova version) and plugins.
The CLI version you specify in the Projects tab Build Settings section is the "Cordova CLI" version that the build system will use to build your app. Each version of the Cordova CLI tools come with a set of "pinned" Cordova framework versions, which vary as a function of the target platform. For example, the Cordova CLI 5.0
platformsConfig
file is "pinned" to the Android Cordova framework version 4.0.0, the iOS Cordova framework version 3.8.0 and the Windows 8 Cordova framework version 3.8.1 (among other targets). The Cordova CLI 4.1.2platformsConfig
file is "pinned" to Android Cordova 3.6.4, iOS Cordova 3.7.0 and Windows 8 Cordova 3.7.1.This means that the Cordova framework version you are using "on device" with a built app will not equal the version number that is in the CLI field that you specified in the Build Settings section of the Projects tab when you built your app. Technically, the target-specific Cordova frameworks can be updated [independently] within a given version of CLI tools, but our build system always uses the Cordova framework versions that were "pinned" to the CLI when it was released (that is, the Cordova framework versions specified in the
platformsConfig
file).The reason you may see Cordova framework version differences between the Emulate tab, App Preview and your built app is:
- The Emulate tab has one specific Cordova framework version it is built against. We try to make that version of the Cordova framework match as closely the default Intel XDK version of Cordova CLI.
- App Preview is released independently of the Intel XDK and, therefore, may support a different version than what you will see reported by the Emulate tab and your built app. Again, we try to release App Preview so it matches the version of the Cordova framework that is the default version of the Intel XDK at the time App Preview is released; but since the various tools are not released in perfect sync, that is not always possible.
- Your app always uses the Cordova framework version that is determined by the Cordova CLI version you specified in the Projects tab's Build Settings section, when you built your app.
- BTW: the version of the Cordova framework that is built into Crosswalk is determined by the Crosswalk project, not by the Intel XDK build system. There is some customization the Crosswalk project team must do to the Cordova framework to include Cordova as part of the Crosswalk runtime engine. The Crosswalk project team generally releases each Crosswalk version with the then current version of the Android Cordova framework. Thus, the version of the Android Cordova framework that is included in your Crosswalk build is determined by the version of Crosswalk you choose to build against.
Do these Cordova framework version numbers matter? Not that much. There are some issues that come up that are related to the Cordova framework version, but they tend to be few and far between. The majority of the bugs and compatibility issues you will experience in your app have more to do with the versions and mix of Cordova plugins you choose and the specific webview present on your test devices. See this blog for more details about what a webview is and why the webview matters to your app: When is an HTML5 Web App a WebView App?.
p.s. The "default version" of the CLI that the Intel XDK uses is rarely the most recent version of the Cordova CLI tools distributed by the Cordova project. There is always a lag between Cordova project releases and our ability to incorporate those releases into our build system and the various Intel XDK components. Also, we are unable to implement every release that is made by the Cordova project; thus the reason why we do not support every Cordova release that is available to Cordova CLI users.
- Q26: How do I add a third party plugin?
- Please follow the instructions on this doc page to add a third-party plugin: Adding Plugins to Your Intel® XDK Cordova* App -- this plugin is not being included as part of your app. You will see it in the build log if it was successfully added to your build.
- Q27: How do I make an AJAX call that works in my browser work in my app?
- Please follow the instructions in this article: Cordova CLI 4.1.2 Domain Whitelisting with Intel XDK for AJAX and Launching External Apps.
- Q28: I get an "intel is not defined" error, but my app works in Test tab, App Preview and Debug tab. What's wrong?
When your app runs in the Test tab, App Preview or the Debug tab the intel.xdk and core Cordova functions are automatically included for easy debug. That is, the plugins required to implement those APIs on a real device are already included in the corresponding debug modules.
When you build your app you must include the plugins that correspond to the APIs you are using in your build settings. This means you must enable the Cordova and/or XDK plugins that correspond to the APIs you are using. Go to the Projects tab and insure that the plugins you need are selected in your project's plugin settings. See Adding Plugins to Your Intel® XDK Cordova* App for additional details.
- Q29: How do I target my app for use only on an iPad or only on an iPhone?
There is an undocumented feature in Cordova that should help you (the Cordova project provided this feature but failed to document it for the rest of the world). If you use the appropriate preference in the
intelxdk.config.additions.xml
file you should get what you need:<preference name="target-device" value="tablet" /> <!-- Installs on iPad, not on iPhone --><preference name="target-device" value="handset" /> <!-- Installs on iPhone, iPad installs in a zoomed view and doesn’t fill the entire screen --><preference name="target-device" value="universal" /> <!-- Installs on iPhone and iPad correctly -->
If you need info regarding the additions.xml file, see the blank template or this doc file: Adding Intel® XDK Cordova Build Options Using the Additions File.
- Q30: Why does my build fail when I try to use the Cordova* Capture Plugin?
The Cordova* Capture plugin has a dependency on the File Plugin. Please make sure you both plugins selected on the projects tab.
- Q31: How can I pinch and zoom in my Cordova* app?
For now, using the viewport meta tag is the only option to enable pinch and zoom. However, its behavior is unpredictable in different webviews. Testing a few samples apps has led us to believe that this feature is better on Crosswalk for Android. You can test this by building the Hello Cordova sample app for Android and Crosswalk for Android. Pinch and zoom will work on the latter only though they both have:
.
Please visit the following pages to get a better understanding of when to build with Crosswalk for Android:
http://blogs.intel.com/evangelists/2014/09/02/html5-web-app-webview-app/
https://software.intel.com/en-us/xdk/docs/why-use-crosswalk-for-android-builds
Another device oriented approach is to enable it by turning on Android accessibility gestures.
- Q32: How do I make my Android application use the fullscreen so that the status and navigation bars disappear?
The Cordova* fullscreen plugin can be used to do this. For example, in your initialization code, include this function
AndroidFullScreen.immersiveMode(null, null);
.You can get this third-party plugin from here https://github.com/mesmotronic/cordova-fullscreen-plugin
- Q33: How do I add XXHDPI and XXXHDPI icons to my Android or Crosswalk application?
The Cordova CLI 4.1.2 build system will support this feature, but our 4.1.2 build system (and the 2170 version of the Intel XDK) does not handle the XX and XXX sizes directly. Use this workaround until these sizes are supported directly:
- copy your XX and XXX icons into your source directory (usually named
www
) - add the following lines to your
intelxdk.config.additions.xml
file - see this Cordova doc page for some more details
Assuming your icons and splash screen images are stored in your source directory (usually named
www
), add lines similar to these into yourintelxdk.config.additions.xml
file (the precise name of your png files may be different than what is shown here):<!-- for adding xxhdpi and xxxhdpi icons on Android --><platform name="android"><icon src="www/xxhdpi.png" density="xxhdpi" /><icon src="www/xxxhdpi.png" density="xxxhdpi" /><splash src="www/splash-port-xhdpi.png" density="port-xhdpi"/><splash src="www/splash-land-xhdpi.png" density="land-xhdpi"/></platform>
The precise names of your PNG files are not important, but the "density" designations are very important and, of course, the respective resolutions of your PNG files must be consistent with Android requirements. Those density parameters specify the respective "res-drawable-*dpi" directories that will be created in your APK for use by the underlying Android OS. NOTE: splash screen references have been added for reference, you do not need to use this technique for splash screens.
You can continue to insert the other icons into your app using the Intel XDK Projects tab.
- copy your XX and XXX icons into your source directory (usually named
- Q34: Which plugin is the best to use with my app?
We are not able to track all the plugins out there, so we generally cannot give you a "this is better than that" evaluation of plugins. Check the Cordova plugin registry to see which plugins are most popular and check Stack Overflow to see which are best supported; also, check the individual plugin repos to see how well the plugin is supported and how frequently it is updated. Since the Cordova platform and the mobile platforms continue to evolve, those that are well-supported are likely to be those that have good activity in their repo.
Keep in mind that the XDK builds Cordova apps, so whichever plugins you find being supported and working best with other Cordova (or PhoneGap) apps would likely be your "best" choice.
See Adding Plugins to Your Intel® XDK Cordova* App for instructions on how to include third-party plugins with your app.
↧
Intel® XDK FAQs - Cordova
↧