Search code examples
javaandroidandroid-customtabs

Chrome custom tab opens as a new tab in chrome not inside the app why?


How can I open my custom tab inside my app without opening Google Chrome in background...

this is my code

String a="http://www.gpamravati.ac.in/gpamravati";
        CustomTabsIntent.Builder builder=new CustomTabsIntent.Builder();
        CustomTabsIntent custom=builder.build();
        custom.intent.setPackage("com.android.chrome");
        builder.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary));
        custom.launchUrl(this, Uri.parse(a));

when I click on website menu item it invokes the chrome custom tab

It opens like this


Solution

  • Finally solved my problem by adding:

    android:launchMode="singleTask"
    

    Just add this code to your manifest under activity

    Below is the output output