I believe that there is a way to pass the json objects from JS to java using phonegap plugin. If anybody knows please help me on this. Thanks in advance buddies
1 Answer
Create a java class like this
public class MyJavaScriptInterface
{
Activity parentActivity;
MyJavaScriptInterface(Activity activity){
parentActivity = activity;
}
public void processData(String jsonString){
/* your processing logic */
}
in your activity
MyWebView.addJavascriptInterface(new MyJavaScriptInterface(this), "MyHandler");
in your html page
<a href="#" data-transition="slide" onClick="window.MyHandler.processData("+jsonString+")">
Change this with your page code (html Page)
1 Comment
baldraider
by sending JSON data like this I'm getting this error
Uncaught SyntaxError: missing ) after argument list", source: file:///android_asset/' my code formatted like this with including JSON data <img src="http://45.55.46.149/wp-content/uploads/2017/12/android-smart-text-selection-350x175.jpg" onClick='window.JavaScriptInterface.showImages("[{"name":"John","age":30,"city":"New York"}]");' />