功能实现:
1.首先在manifest中目标Activity中添加
<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="xxx.xxx"
android:pathPrefix="/xxx"
android:scheme="xxx" />
</intent-filter>
上面的xxx填写,以“myapp://digo.com/app”为例
<data
android:host="digo.com"
android:pathPrefix="/app"
android:scheme="myapp" />
2.如果想要在目标内获取传递的参数,比如“myapp://digo.com/app?id=xxx”(xxx为任意数)
Intent intent = getIntent();
String action = intent.getAction();
if (Intent.ACTION_VIEW.equals(action)) {
Uri uri = intent.getData();
if (uri != null) {
productId = uri.getQueryParameter("id");
}
}
网友评论