Cordova SendJavascript Not Working For Android ProcessMessage Failed: Error: Not Defined:10
I am building a phonegap-android application and as a part of the flow, I am calling an activity from my javascript side using javascriptInterface This looks like public void onCre
Solution 1:
Had a similar issue and I was going MENTAL with it, finally I found came up with an "UGLY" but working solution:
Instead of passing the data back from the onActivityResult do the following.
1) Define a global variable in your JAVA and store the result in that global variable
2) DO this in the onActivityResult:
Log.i("MAIN_ACTIVITY", "*************** received data"+ data);
appView.sendJavascript("jsi_getImage();");
3) Define another function in you JAVA something like:
public String send_picture() {
return previously_defined_global_variable;
}
4) In your Javascript function called jsi_getImage, make another call to send_picture() like:
function jsi_getImage(){
alert(window.MainActivity.send_picture());
}
Make sure that you are sending only string data between Java and Javascript (BASE64 encode for image)
Hope it helps
Post a Comment for "Cordova SendJavascript Not Working For Android ProcessMessage Failed: Error: Not Defined:10"