码迷,mamicode.com
首页 > 移动开发 > 详细

android webview(外部浏览器)调起app

时间:2016-06-14 14:02:27      阅读:408      评论:0      收藏:0      [点我收藏+]

标签:

  最近写的项目中涉及外部浏览器以及项目webview中调起app,所以总结下,和大家分享下。

  总的实现方法还是比较简单的,

  1:在清单中注册

  首先在AndroidManifest文件中,注册一个过滤器

 

<intent-filter >
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="xxx" android:host="xxx"/>
</intent-filter>

其中scheme和host如下:

scheme://host:port/path

例如:nearbar://com.nearbar.android:200/folder/subfolder/etc 
\---------/  \---------------------------/ \---/ \--------------------------/ 
scheme                 host               port        path 
                \--------------------------------/ 
                          authority    

2:在mainactivity中接收

  

if (Intent.ACTION_VIEW.equals(action)) {
Uri uri = i_getvalue.getData();
String data = uri.toString();

}

由于我的项目中url中传过来的是json串,通过解析来判断具体的操作。

 

android webview(外部浏览器)调起app

标签:

原文地址:http://www.cnblogs.com/zhjing/p/5583629.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!