Reputation: 6369
We use Chrome custom tabs in our app to open links. We have issue on Samsung S6 Edge. When we click on the link in our app, this device opens its own browser(called Internet) instead of Chrome custom tabs. When you press back button, sometimes instead of returning back to our app it will open Internet app from stack(if you already used this Internet app for browsing recently). If you didn't use recently Internet app for browsing, press back will correctly open you your app.
Upvotes: 2
Views: 2031
Reputation: 4976
Custom Tabs is an open specification and other browsers besides Chrome may support it.
Having said that, it seems that there's a bug on the current Samsung's Internet Browser implementation (4.0.10-51) that causes the mentioned behaviour.
A temporary workaround would be to ignore the Samsung IB package when opening a Custom Tab. You can check how to discover which browsers support Custom Tabs on the getPackageNameToUse method on the Github Demo.
Modify the method to ignore the com.sec.android.app.sbrowser
package. Then, force the package you want to use to open the Custom Tab like this:
customTabsIntent.intent.setPackage(packageName);
customTabsIntent.launchUrl(activity, uri);
I would also recommend taking a look on the Custom Tabs Best Practices to see how to prepare for the scenarios where more than one browser that supports Custom Tabs are installed in the system.
UPDATE: It seems that the latest version from Samsung's Internet Browser (4.2) has those issues fixed. The improved solution would be to check if the version of the installed browser is a compatible one. Something like the answer on this StackOverflow question can be used.
Upvotes: 5
Reputation: 53
I checked with many Custom Tab client in Samsung latest phones.
I see that this issue is not observed in Samsung phones like Note 7 which has the latest version of their default Browser i.e Version 4.2 (Procedure to check version Menu options -> Settings -> About Internet)
So above solution of ignoring or bypassing "com.sec.android.app.sbrowser" package name is not necessary for their latest phones.
Upvotes: 2
Reputation: 721
Workaround in Googles example code for custom tabs: CustomTabsHelper.java
// Get all apps that can handle VIEW intents.
List<ResolveInfo> resolvedActivityList = pm.queryIntentActivities(activityIntent, 0);
List<String> packagesSupportingCustomTabs = new ArrayList<>();
for (ResolveInfo info : resolvedActivityList) {
Intent serviceIntent = new Intent();
serviceIntent.setAction(ACTION_CUSTOM_TABS_CONNECTION);
serviceIntent.setPackage(info.activityInfo.packageName);
if (pm.resolveService(serviceIntent, 0) != null) {
//If the packagename is not the samsung thing, add it to the list
if (! info.activityInfo.packageName.equals("com.sec.android.app.sbrowser")) {
packagesSupportingCustomTabs.add(info.activityInfo.packageName);
}
}
}
Upvotes: 1