Android原生主动调用H5方法

1、添加方法

mWebView.addJavascriptInterface(new JsInterface(), "android");

2:android中的写法,下面这段很重要

String path = "http://test123.html";
String method = "javascript:displayImg('" + path + "')";
mWebView.loadUrl(method);

3、h5中的方法:

//点击上传
   function displayImg(url){
       //这时H5调用displayImg方法就可以获取到这个url 

   }

猜你喜欢

转载自blog.csdn.net/professionIT/article/details/86542271