- Notifications
You must be signed in to change notification settings - Fork106
open-android/BridgeWebView
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
开源地址:https://github.com/open-android/BridgeWebView
PS:如果觉得文章太长,你也可观看该课程的视频,亲,里面还有高清,无码的福利喔
- 爱生活,爱学习,更爱做代码的搬运工,分类查找更方便请下载黑马助手app
allprojects { repositories { maven { url "https://jitpack.io" } }}compile 'com.github.open-android:BridgeWebView:v1.0'<com.itheima.view.BridgeWebViewandroid:id="@+id/bdwebview"android:layout_width="match_parent"android:layout_height="match_parent"/>mBdwebview = (BridgeWebView) findViewById(R.id.bdwebview);//初始化BridgeWebViewmBdwebview.loadUrl("http://10.0.3.2:63343/BridgeWebView/index.html");//显示H5页面mBdwebview.addBridgeInterface(new MyJavaSctiptInterface(mBdwebview, this));//注册桥梁类,该类负责H5和android通信public class MyJavaSctiptInterface{ private Activity mActivity; public MyJavaSctiptInterface(Activity mActivity) { this.mActivity = mActivity; } public void callPhone(String[] strs){//拨号 JSONObject jsonObject = new JSONObject(strs[0]); String phone = jsonObject.optString("phone"); Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone)); mActivity.startActivity(intent); }}$("#btn1").on("click", function(){ var method = "callPhone";//js调用的android方法名 var params = {"phone":"10086", "callback":""};//callback用于回调js callAndroidMethod(method, params);}); /** * 统一管理js调用安卓方法 * @param method 方法名 * @param params 向android传参数 数组格式 */var callAndroidMethod = function(method, params){ window.jsInterface.invokeMethod(method, [JSON.stringify(params)]);}详细的使用方法在DEMO里面都演示啦,如果你觉得这个库还不错,请赏我一颗star吧~~~
欢迎关注微信公众号
About
H5和Android通信框架,让H5和Android相互调用更加简单。
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.




