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 onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
super.init();
appView.addJavascriptInterface(this, "Android");
super.loadUrl(Config.getStartUrl());
}
now I also want to send back some data from my activity to the cordova webview.
I have defined a function in my javascript file which I want to call
function jsi_getData(data) {
console.log("JSI GET IMAGE INVOKED ON JAVASCRIPT SIDE");
alert(data);
}
and in my android code, inside onActivityResult, I am calling this javascript function
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == 12321){
//do some work
Log.i("MAIN_ACTIVITY", "*************** received data"+ data);
appView.sendJavascript("javascript:jsi_getImage("+data+");");
}
}
This gives me the following error
09-16 18:18:27.211: I/Web Console(28991): processMessage failed: Message: Jjavascript:jsi_getData('data');:1034
09-16 18:18:27.211: I/Web Console(28991): processMessage failed: Error: ReferenceError: jsi_getImage is not defined:1035
09-16 18:18:27.211: I/Web Console(28991): processMessage failed: Stack: ReferenceError: jsi_getImage is not defined
09-16 18:18:27.211: I/Web Console(28991): at eval (eval at processMessage (file:///android_asset/www/js/libs/cordova.js:996:26), <anonymous>:1:1)
09-16 18:18:27.211: I/Web Console(28991): at processMessage (file:///android_asset/www/js/libs/cordova.js:996:13)
09-16 18:18:27.211: I/Web Console(28991): at Function.androidExec.processMessages (file:///android_asset/www/js/libs/cordova.js:1063:13)
09-16 18:18:27.211: I/Web Console(28991): at pollOnce (file:///android_asset/www/js/libs/cordova.js:933:17):1036
09-16 18:18:27.481: I/Adreno200-EGLSUB(28991): <ConfigWindowMatch:2087>: Format RGBA_8888.
I also changed aappView.sendJavascript() to this.sendJavascript() and I still have the same error
Please help as I am litrally stuck!! This would be very helpful.
Thanks