I have implemented applinks to handle all the url's from my domain as follows
<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>
but i would like to open some links from the same domain in customtabs.I am implementing this logic to invoke those links in 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);
but those links were captured by my applink intent and it goes on in a loop.What am i missing? Any ideas or suggestions would be useful.
Setting the package on the Intent that launches the CustomTabs should force it to open Chrome.
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.intent.setPackage("com.android.chrome");
customTabsIntent.launchUrl(
context,Uri.parse("http://www.example.com/unhandled"));
Also, since Chrome is not the only browser that supports Custom Tabs, I'd recommend following the best practices, and supporting other browsers as well.