android4.4 js调用java
2015-09-29 20:31
501 查看
1.使用webview需要加入权限到AndroidManifest.xml
2.webview绑定js对象
3.java 端js对象
4.js调用方法
<uses-permission android:name="android.permission.INTERNET"/>
2.webview绑定js对象
wv.getSettings().setJavaScriptEnabled(true); wv.addJavascriptInterface(new DemoJavaScriptInterface(), "demo");
3.java 端js对象
final class DemoJavaScriptInterface { DemoJavaScriptInterface() { } /** * This is not called on the UI thread. Post a runnable to invoke * loadUrl on the UI thread. */ @JavascriptInterface public void clickOnAndroid() { Log.i(LOG_TAG, "--------------------------------"); } }
4.js调用方法
<input type="button" onclick="demo.clickOnAndroid()" value="btn1" />
相关文章推荐
- 使用反射机制实现对类中私有方法的调用
- android的Drawable资源
- android 按两次返回键退出
- android中日期加天数的方法
- Android 随着输入框控件的清除功能ClearEditText,抄IOS输入框
- android自定义dialog
- android学习-----多线程
- android进程间通讯方式
- Android开发指南
- Android系统中iptables的应用(二)BandwidthController
- Android之基于BaseAdapter和SimpleAdapter的GridView
- Android仿格瓦拉循环滚动View
- Android Studio 创建文件是 Create by administrator修改
- Android 开机启动
- 如何提高android代码的质量(CheckStyle、Findbugs、PMD、Lint)
- android中textvie中的文字间距属性设置
- (转)Android自定义统计图(柱状图,折线图,饼状图)
- android:windowSoftInputMode属性详解
- 19.Android 清除按钮EditText - AIEditText
- Android 布局学习