How to implement intelxdk using JavaScript in HTML? - intel-xdk

How & where should I implement this JavaScript method below in my index.html file?
I am using this code to access the native code of android in intelxdk
smsplugin.startReception(successCallback(result),failureCallback(error));

You should implement your code in your .js file:
document.addListener('intel.xdk.device.ready', onXdkReady, false);
function onXdkReady() {
if (smsplugin) {
smsplugin.startReception(successCallback(result),failureCallback(error));
}
}
See here for more info.

Related

Load Local HTML/JavaScript/CSS Inside NativeScript App

With a NativeScript iOS and Android app using Angular, how do I load, inside of a WebView, a locally stored html file that has JS and CSS references? I am able to display the WebView but I get the error that the file is not found because I do not know where to point the src from my component.
Currently I have the files inside src/assets and in there is the index.html
Is there a more appropriate place to store these files within the app? Is there a better way to display this than a WebView? How do I reference this file as the source of a WebView?
I will also be needing to know how to reference a file the app downloads. Where does iOS and Android store downloaded files from within the app? How do i reference these files from my WebView?
Thank you.
You have to use absolute path while importing local JS / CSS / Image into WebView. Here is a Playground sample. Unlike the given example if you want to load files those are packed with app, simply use app directory instead with right path to file.
I'm using path like:
src='~/assets/player.iframe.html'
And in the webpack.config.js I just added
new CopyWebpackPlugin([
{ from: { glob: "assets/**" } }, <= Added this row
{ from: { glob: "fonts/**" } },
{ from: { glob: "**/*.jpg" } },
...

Touch UI v/s Classic UI in AEM

How do we check whether the html page in Adobe Experience Manager/CQ5 is opened in touch mode or classic mode?
You can add dependency to /libs/wcm/foundation/components/utils/AuthoringUtils.js and then call AuthoringUtils.isTouch and AuthoringUtils.isClassic to check whether it is currently in touch or the classic mode. For e.g., your JS Use API would look something like below.
"use strict";
use(["/libs/wcm/foundation/components/utils/AuthoringUtils.js"], function (AuthoringUtils) {
if (AuthoringUtils.isTouch) {
// do something
} else {
// do something else
}
// rest of the things
}

Java annotation using Pyjnius

I copied this code to use android native WebView in my Kivy application. Works perfectly :)
Now, I would like to bind my JavaScript with my Kivy application.
I've read through this guide:
...
/** Show a toast from the web page */
#JavascriptInterface
public void showToast(String toast) {
...
How can I create a PyJnius class that has #JavascriptInterface annotation?
Thanks!

pause and resume listeners not working in phonegap on iOS4.3 and iOS 5

I was making a native app in iPhone4 with iOS 4.3
in my Body onLoad i m adding
document.addEventListener("pause", Game.prototype.pauseListener.bind(this), false);
document.addEventListener("resume", Game.prototype.resumeListener.bind(this), false);
and in that same file i m writing a function
Game.prototype.resumeListener= function()
{
console.log("in resumeListener");
this.PauseGame(false);
}
Game.prototype.pauseListener= function()
{
this.PauseGame(true);
}
this code is working perfectly fine in Android and when i manually minimise the app, but when the application is interrupted by a voice incoming call the application dont pause.
Basically Pause and Resume event are not fired.
I m using Phonegap1.4.1
I believe your event listeners are not being established because you are using Object.bind() on the handler functions, and .bind() is not available in the iOS WebKit widget. (This is surpising because .bind() is available in the desktop WebKit (Chrome and Safari) versions.)
The easy solution is to add a polyfill definition for Object.bind(). I use the one from the MDN bind documentation page, and haven't had any problems with it.
sorry but i cant make a comment yet ;)
have you checked the two other events (active and resign only for ios)? more information: http://shazronatadobe.wordpress.com/2012/03/14/apache-cordova-lifecycle-events-in-ios-4-versus-ios-5/
or see iOS Quirks in the documentation: http://docs.phonegap.com/en/1.6.1/cordova_events_events.md.html#pause
You need to add your listeners in the deviceready instead of in the onLoad.
Just like here for example
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
document.addEventListener("pause", onPause, false);
}
function onPause() {
}
Hope it helps :)

How to Bind Load event for Image in jQueryMobile

I have a mobile website running jQuery Mobile 1.0a2 and I'm currently testing in Mobile Safari for Firmware 4.1 via the iPhone Simulator.
I cannot seem to bind to the load event for an image.
I have a simple gallery of thumbnails and a large image. When you click on a thumbnail it changes the src attribute of the main img
The js for that uses the live('click' method to bind and it works just fine.
$('.gallery-navigation img').live('click',function() {
// change source of main image to new
$.mobile.pageLoading(); // show jquerymobile loading message
});
My problem is that I need feedback on this click, so I wanted to show a loading message (provided by jquerymobile) and then hide it once the image loads.
Where #gallery_image_large is the actual <img> where the src is changing, I tried the following:
$("#gallery_image_large").bind("load", function () {
$.mobile.pageLoading(true); // hide jquerymobile loading message
});
This works in Safari on my desktop but does not in the iPhone Simulator mentioned above.
For reference:
jQuery Mobile Loading Message Methods
UPDATE: I am experimenting with JQuery Image load fails on MobiOne iPhone simulator, which explains how to implement the .load manually by "checking .complete".
I changed the structure of my jquery and it's seemed to have fixed it!
$('#gallery_image_large').one('load',function() {
try { // a grade
$.mobile.pageLoading(true);
} catch(err) { // low grade
}
}).attr('src',full_src);
(as you can see, I opt'd for a try { .. } catch { .. } to verify jquerymobile is available.
Although I didn't use the solution (directly) from JQuery Image load fails on MobiOne iPhone simulator, the manual firing of load via .complete is probably a good solution for anyone else out there!