Thursday, 15 September 2011

java - Is it possible to call into javascript from a background thread running in a cordova android plugin -



java - Is it possible to call into javascript from a background thread running in a cordova android plugin -

i have cordova application using native plugin on android (other platforms come).

my plugin loaded @ application start (<param name="onload" value="true" /> in plugin.xml) , native code work in initialize method (overloaded cordovaplugin class).

essentially, work in initialize method causes event generated @ later time, , need deliver event javascript api.

is there way can asynchronously phone call javascript native side of plugin, without first having called plugin javascript side? (a phone call js->java give me callbackcontext utilize issue callback, assume).

i found https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/nativetojsmessagequeue.java don't know how utilize , cannot find documentation - i'm not sure if works or intended public use.

can utilize webview.loadurl("javascript: ... "); phone call in javascript side, or disrupt or interfere cordova framework running in js (if any)?

is there recommended way of acomplishing this, , supported across multiple platforms (or concepts applicable other platforms?)

thanks

currently using workaround - have user phone call through plugin (js->java) , in doing provide callback function registering.

in java side store callbackcontext utilize later. 1 of import thing, of import when utilize callbackcontext.sendpluginresult, pluginresult pass has marked pluginresult.setkeepcallback(true) method, otherwise first phone call callbackcontext cause context become invalid future calls.

i haven't noticed threading issues , not sure (but hopeful) applicable other platforms.

java javascript android cordova

No comments:

Post a Comment