deep-linking - 未处理的应用程序链接的自定义选项卡

标签 deep-linking applinks chrome-custom-tabs android-customtabs

我已实现 应用链接处理来自我的域的所有 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> 

但我想在 中打开来自同一域的一些链接自定义标签 .我正在实现这个逻辑来调用 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);

但是这些链接是由我的 applink 意图捕获的,并且循环进行。我错过了什么?任何想法或建议都会很有用。

最佳答案

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

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

此外,由于 Chrome 不是唯一支持自定义标签的浏览器,我建议遵循 best practices ,并支持其他浏览器。

关于deep-linking - 未处理的应用程序链接的自定义选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47576324/

相关文章:

ios - 在 2017 年单击帖子时,Facebook 应用程序链接不会打开应用程序

android - 有没有办法用 Espresso 测试 Chrome 自定义标签?

ios - CustomPushHandler 代表不被称为深度链接 Urban Airship

ios - 无法在 iOS 上与 Chrome 深度链接

swift - 应用程序关闭时动态链接不起作用,仅在后台运行时

ios - 分支深层链接未打开应用程序

java - Facebook Android 应用程序链接打开 Facebook 页面而不是 Play 商店

java - 无法在我的 Android 应用程序中启动 Chrome CustomTabsIntent

android - Chrome 自定义标签 EXTRA_REFERRER 不起作用

google-analytics - 网络广告系列归因于应用安装