我相信有一种方法可以使用phonegap插件将json对象从JS传递给java。如果有人知道请帮助我。在此先感谢好友
答案 0 :(得分:1)
像这样创建一个java类
public class MyJavaScriptInterface
{
Activity parentActivity;
MyJavaScriptInterface(Activity activity){
parentActivity = activity;
}
public void processData(String jsonString){
/* your processing logic */
}
在您的活动中
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)