- 什么是URL Scheme?
简略的说就是android中的一种页面内跳转协定,不便app页面的内的跳转
2.什么时候应用
服务器下发跳转门路,客户端依据 服务器下发跳转门路跳转相应的页面
H5页面点击描点,依据描点具体跳转门路APP端跳转具体的页面
APP端收到服务器端下发的PUSH告诉栏音讯,依据音讯的点击跳转门路跳转相干页面
APP依据URL跳转到另外一个APP指定页面
3.协定格局
zymobi://3g2win:9999/macthDetail?macthId=222&time=10001 复制代码
4.在app中如何应用
在AndroidManifest.xml中对activity标签减少intent-filter设置Schema
<activity android:name=".SecondActivity"> <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="zymobi" android:host="3g2win" android:port="9999" android:path="/macthDetail" /> </intent-filter> </activity> 复制代码
留神:
<action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> 复制代码
5.如何调用
1.在html中调用非常简单
<a href="zymobi://3g2win:9999/macthDetail?macthId=222&time=10001">关上源生利用指定的页面</a> 复制代码
2.在源生利用中调用也很简略
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("zymobi://3g2win:9999/macthDetail?macthId=222&time=10001")); startActivity(intent); 复制代码
6.在源生界面获取uri和各个参数
Intent intent = getIntent(); Uri data = intent.getData(); // String action = intent.getAction(); String scheme = intent.getScheme(); Set<String> categories = intent.getCategories(); Log.e("TAG", "data==========="+data); Log.e("TAG", "action==========="+action); Log.e("TAG", "categories==========="+categories); Log.e("TAG", "DataString==========="+intent.getDataString()); Log.e("TAG", "=============================="); Log.e("TAG", "scheme==========="+scheme); Log.e("TAG", "id ==========="+data.getQueryParameterNames()); Log.e("TAG", "host==========="+data.getHost()); Log.e("TAG", "path==========="+data.getPath()); Log.e("TAG", "port==========="+data.getPort()); 复制代码
输入后果
4-11 18:13:56.335 5198-5198/com.phone.myapplication E/TAG: data===========zymobi://3g2win:9999/macthDetail?goodsId=10011002&time=1111 04-11 18:13:56.335 5198-5198/com.phone.myapplication E/TAG: action===========android.intent.action.VIEW 04-11 18:13:56.335 5198-5198/com.phone.myapplication E/TAG: categories===========null 04-11 18:13:56.335 5198-5198/com.phone.myapplication E/TAG: DataString===========zymobi://3g2win:9999/macthDetail?goodsId=10011002&time=1111 04-11 18:13:56.335 5198-5198/com.phone.myapplication E/TAG: ============================== 04-11 18:13:56.335 5198-5198/com.phone.myapplication E/TAG: scheme===========zymobi 04-11 18:13:56.335 5198-5198/com.phone.myapplication E/TAG: id ===========[goodsId, time] 04-11 18:13:56.335 5198-5198/com.phone.myapplication E/TAG: host===========3g2win 04-11 18:13:56.335 5198-5198/com.phone.myapplication E/TAG: path===========/macthDetail 04-11 18:13:56.335 5198-5198/com.phone.myapplication E/TAG: port===========9999 复制代码
具体含意能够比照传入的参数
- 判断Schema是否无效
判断Schema是否无效,也能够说判断利用是否装置(在确定要启动的利用曾经配置了scheme)
app源生判断Sheme是否无效
Intent intent = newIntent(Intent.ACTION_VIEW, Uri.parse("zymobi://3g2win:9999/macthDetail?macthId=222&time=10001")); List<ResolveInfo> activities =packageManager.queryIntentActivities(intent, 0); boolean isValid = !activities.isEmpty(); Toast.makeText(this,isValid+"",Toast.LENGTH_LONG).show();
最初
如果你感觉此文对你有一丁点帮忙,点个赞。或者能够退出我的开发交换群:1025263163互相学习,咱们会有业余的技术答疑解惑
如果你感觉这篇文章对你有点用的话,麻烦请给咱们的开源我的项目点点star:http://github.crmeb.net/u/defu不胜感激 !
残缺源码下载地址:https://market.cloud.tencent….
PHP学习手册:https://doc.crmeb.com
技术交换论坛:https://q.crmeb.com