Monday, 2 September 2013

Consecutive Javascript calls in Android webview

Consecutive Javascript calls in Android webview

I have created webview with javascript enabled and loaded asser folder
file as URL in the webview. In this webview I am calling native methods
like getContacts, addItemToDictionary, getItemFromDictionary consecutively
like the below structure,
getContacts();
addItemToDictionary(key,value);
getItemFromDictionary(key);
But I am unable to get all the native call values, the second call is not
success, since getting callback is not defined at null:1 error. In iOS
webview the following code is used in html file for getting values from
consecutive native calls.
var iframe = document.createElement("IFRAME");
iframe.setAttribute("src", "js-frame:myObjectiveCFunction";
document.documentElement.appendChild(iframe);
iframe.parentNode.removeChild(iframe);
iframe = null;
Reference Link :
http://blog.techno-barje.fr/post/2010/10/06/UIWebView-secrets-part3-How-to-properly-call-ObjectiveC-from-Javascript/
Is there any way to get the values from consecutive calls in Android webview?

No comments:

Post a Comment