2

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.

Rafael
  • 6,091
  • 5
  • 54
  • 79

3 Answers3

5

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.

Community
  • 1
  • 1
andreban
  • 4,621
  • 1
  • 20
  • 49
  • `customTabsIntent.intent` not recognising **intent** – Rafael Apr 04 '16 at 05:13
  • Take a look this code, maybe it helps: https://github.com/GoogleChrome/custom-tabs-client/blob/master/demos/src/main/java/org/chromium/customtabsdemos/CustomTabActivityHelper.java#L48-L64 – andreban Apr 04 '16 at 08:49
  • Like it says in the question, "... 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..." this is still an issue with Samsung Internet version 7.4.00.70 – Dhunju_likes_to_Learn Sep 12 '18 at 20:50
2

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.

  • The version of the Samsung package can be verified using something like this: http://stackoverflow.com/questions/8988958/checking-external-app-version-name-in-android – andreban Sep 29 '16 at 11:21
1

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);
            }

        }
    }
Marius Kohmann
  • 713
  • 1
  • 8
  • 11