Android 应用 link 多个 intent 过滤器主机和清单合并不起作用
Android app link multiple intent filter hosts and manifest merge not working
我正在使用构建变体并希望根据变体捕获其他链接。我希望所有变体都从主机 1 捕获链接,所以我在主 AndroidManifest.xml
文件中声明了一个 intent-filter
,如下所示:
<activity android:name=".activity.DeepLinkActivity"
android:noHistory="true">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:host="hostOne.com" android:path="/page.aspx" android:scheme="http"/>
</intent-filter>
</activity>
我还为其他变体生成部分清单,例如 hostTwo.com,如下所示:
<?xml version="1.0" encoding="UTF-8"?><manifest package="com.package.my.domain">
<application xmlns:android="http://schemas.android.com/apk/res/android" android:name="AlarmMobile">
<activity android:name=".activity.DeepLinkActivity">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="http://" android:host="hostTwo.com" android:path="/page.aspx"/>
</intent-filter>
</activity>
</application>
</manifest>
根据构建变体 (based upon the documentation here) 和 Android 工作室的合并清单视图显示主机二的 intent-filter
已添加到最终版本中,它被放置在一个适当命名的文件夹中合并清单,但是,模拟器或实际设备无法捕获用于第二个主机的意图。
我正在命令提示符中生成这样的意图:
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://hostone.com/page.aspx"
适用于 hostone,但正在做
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://hosttwo.com/page.aspx"
将启动浏览器,因为应用无法捕获它。
android 应用程序链接是否仅适用于一个主机名?还有什么我可以尝试的吗?
我发现部分清单不正确。在 intent-filter
的 data
标签中,android:scheme="http://"
由于尾随 ://
.
而无效
根据 google's documentation,Android 构建 intent-filter
URI 如下:<scheme>://<host>:<port>/<path>
因此无需在声明中包含它。
将我的声明更改为 android:scheme="http"
后,合并继续成功并且 OS 尝试验证部分清单中定义的链接!
更正了部分清单:
<?xml version="1.0" encoding="UTF-8"?><manifest package="com.package.my.domain">
<application xmlns:android="http://schemas.android.com/apk/res/android" android:name="AlarmMobile">
<activity android:name=".activity.DeepLinkActivity">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="http" android:host="hostTwo.com" android:path="/page.aspx"/>
</intent-filter>
</activity>
</application>
</manifest>
我正在使用构建变体并希望根据变体捕获其他链接。我希望所有变体都从主机 1 捕获链接,所以我在主 AndroidManifest.xml
文件中声明了一个 intent-filter
,如下所示:
<activity android:name=".activity.DeepLinkActivity"
android:noHistory="true">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:host="hostOne.com" android:path="/page.aspx" android:scheme="http"/>
</intent-filter>
</activity>
我还为其他变体生成部分清单,例如 hostTwo.com,如下所示:
<?xml version="1.0" encoding="UTF-8"?><manifest package="com.package.my.domain">
<application xmlns:android="http://schemas.android.com/apk/res/android" android:name="AlarmMobile">
<activity android:name=".activity.DeepLinkActivity">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="http://" android:host="hostTwo.com" android:path="/page.aspx"/>
</intent-filter>
</activity>
</application>
</manifest>
根据构建变体 (based upon the documentation here) 和 Android 工作室的合并清单视图显示主机二的 intent-filter
已添加到最终版本中,它被放置在一个适当命名的文件夹中合并清单,但是,模拟器或实际设备无法捕获用于第二个主机的意图。
我正在命令提示符中生成这样的意图:
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://hostone.com/page.aspx"
适用于 hostone,但正在做
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://hosttwo.com/page.aspx"
将启动浏览器,因为应用无法捕获它。
android 应用程序链接是否仅适用于一个主机名?还有什么我可以尝试的吗?
我发现部分清单不正确。在 intent-filter
的 data
标签中,android:scheme="http://"
由于尾随 ://
.
根据 google's documentation,Android 构建 intent-filter
URI 如下:<scheme>://<host>:<port>/<path>
因此无需在声明中包含它。
将我的声明更改为 android:scheme="http"
后,合并继续成功并且 OS 尝试验证部分清单中定义的链接!
更正了部分清单:
<?xml version="1.0" encoding="UTF-8"?><manifest package="com.package.my.domain">
<application xmlns:android="http://schemas.android.com/apk/res/android" android:name="AlarmMobile">
<activity android:name=".activity.DeepLinkActivity">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="http" android:host="hostTwo.com" android:path="/page.aspx"/>
</intent-filter>
</activity>
</application>
</manifest>