我已经实现了应用链接来处理我域中的所有 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中打开来自同一域的一些链接。我正在实现这个逻辑来调用 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 意图捕获的,并且它会循环进行。我错过了什么?任何想法或建议都会很有用。