1 回答
TA贡献1772条经验 获得超5个赞
1) js调用android的方法:
WebView wView;
wView. addJavascriptInterface (Object obj, String interfaceName);
是实例化一个对象,在html的js中调用,第二个参数是实例化对象的别名,如果要使用这个obj,则在js中使用的名字
就是interfaceName。
public class jsWebDemo extends Activity {
WebView wView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
wView = (WebView)findViewById(R.id.wv1);
WebSettings wSet = wView.getSettings();
wSet.setJavaScriptEnabled(true);
ProxyBridge pBridge = new ProxyBridge();
wView.addJavascriptInterface(pBridge, "AliansBridge");
wView.loadUrl("file:///android_asset/index.html");
- 1 回答
- 0 关注
- 928 浏览
添加回答
举报