Android 通过URL scheme 实现点击浏览器中的URL链接,启动特定的App,并调转页面传递参数
2017-02-17 15:16
861 查看
1、首先做成HTML的页面,页面内容格式如下:
例如:
2、Android端开发
3.在onCreate里面调用:
<a href="[scheme]://[host]/[path]?[query]">启动应用程序</a>
例如:
// 自动加载 <iframe src="zhang://my.com/main" style="display:none"><h3>main页面</h3></iframe> // 点击跳转 <a href="myscheme://www.orangecpp.com:80/mypath?key=mykey">Click</a> 参数含义: scheme:判别启动的App。 ※详细后述 host:适当记述 path:传值时必须的key ※没有也可以 query:获取值的Key和Value ※没有也可以
2、Android端开发
<intent-filter> <action android:name="android.intent.action.MAIN"/> <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:host="my.com" android:path="/main" android:scheme="zhang"/> </intent-filter>
3.在onCreate里面调用:
Intent i_getvalue = getIntent(); String action = i_getvalue.getAction(); if(Intent.ACTION_VIEW.equals(action)){ Uri uri = i_getvalue.getData(); if(uri != null){ String name = uri.getQueryParameter("name"); String age= uri.getQueryParameter("age"); } } Intent intent =getIntent(); Log.e(TAG, "scheme:" +intent.getScheme()); Uri uri =intent.getData(); Log.e(TAG, "scheme: "+uri.getScheme()); Log.e(TAG, "host: "+uri.getHost()); Log.e(TAG, "port: "+uri.getPort()); Log.e(TAG, "path: "+uri.getPath()); Log.e(TAG, "queryString: "+uri.getQuery()); Log.e(TAG, "queryParameter: "+uri.getQueryParameter("key")); 显示的log信息 E/MainActivity: scheme:myscheme E/MainActivity: scheme: myscheme E/MainActivity: host: www.orangecpp.com E/MainActivity: port: 80 E/MainActivity: path: /mypath E/MainActivity: queryString: key=mykey E/MainActivity: queryParameter: mykey
相关文章推荐
- Android 通过URL scheme 实现点击浏览器中的URL链接,启动特定的App,并调转页面传递参数
- Android 通过URL scheme 实现点击浏览器中的URL链接,启动特定的App,并调转页面传递参数
- android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
- android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
- Android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
- Android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
- Android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
- Android实现通过浏览器点击链接打开本地应用(APP),并获取到传递的数据
- Android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
- Android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据(转)
- Android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
- Android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
- Android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
- Android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
- android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
- Android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
- Android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
- Android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
- android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
- android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据