未处理的applinks的自定义标签

Abi*_*ash 3 deep-linking applinks chrome-custom-tabs android-customtabs

我已经实现了applinks来处理我域中的所有url,如下所示

    <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="www.example.com"
                android:scheme="http" />
     </intent-filter> 
Run Code Online (Sandbox Code Playgroud)

但我想在customtabs中打开来自同一域的一些链接.我正在实现这个逻辑来调用customtabs中的那些链接

    CustomTabsServiceConnection connection = new CustomTabsServiceConnection() {
        @Override
        public void onCustomTabsServiceConnected(ComponentName componentName, CustomTabsClient client) {
            client.warmup(0L);
            CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
            builder.setInstantAppsEnabled(false);
            builder.setToolbarColor(context.getResources().getColor(R.color.pure_white));
            builder.setSecondaryToolbarColor(context.getResources().getColor(R.color.pure_white));
            builder.setShowTitle(true);
            CustomTabsIntent customTabsIntent = builder.build();
            customTabsIntent.launchUrl(context,Uri.parse("http://www.example.com/unhandled"));
        }
        @Override
        public void onServiceDisconnected(ComponentName name) {}
    };
    CustomTabsClient.bindCustomTabsService(context, "com.android.chrome", connection);
Run Code Online (Sandbox Code Playgroud)

但这些链接是我的applink意图捕获的,它继续循环.我错过了什么?任何想法或建议都会有用.

and*_*ban 5

在启动CustomTabs的Intent上设置包应该强制它打开Chrome.

CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.intent.setPackage("com.android.chrome");
customTabsIntent.launchUrl(
    context,Uri.parse("http://www.example.com/unhandled"));
Run Code Online (Sandbox Code Playgroud)

此外,由于Chrome不是唯一支持自定义标签的浏览器,因此我建议您遵循最佳做法,并支持其他浏览器.