Skip to content Skip to sidebar Skip to footer

Exit_animation_bundle Not Working With Chrome Custom Tabs

I'm trying to incorporate Chrome Custom Tabs in my app and I'm having difficulty getting the exit animation working. I'm following the docs found here: Link The code I'm using is

Solution 1:

The recommended way to integrate your app with Custom Tabs is to use the Android Support Library.

To use it, add com.android.support:customtabs:23.0.0 as a compile dependency to your build.gradle.

Then, to set the exit animations and start the Custom Tab, do:

CustomTabsIntentcustomTabsIntent=newCustomTabsIntent.Builder()
            .setExitAnimations(this,
                    android.R.anim.slide_in_left, android.R.anim.slide_out_right)
            .build();
    customTabsIntent.launchUrl(this, Uri.parse("http://www.example.com"));

Check the demos module in the GitHub sample for more details on how to use it with the Android Support Library.

To open it without the Support Library, you have to make sure you are setting the session extra. The code below will open a Custom Tab and properly set the exit animation.

publicstaticfinalStringEXTRA_EXIT_ANIMATION_BUNDLE="android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE";

publicstaticfinalStringEXTRA_SESSION="android.support.customtabs.extra.SESSION";

publicvoidopenCustomTab() {
    Intentintent=newIntent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));

    Bundlebundle= ActivityOptions
            .makeCustomAnimation(
                    this, android.R.anim.slide_in_left, android.R.anim.slide_out_right)
            .toBundle();

    BundleextrasBundle=newBundle();
    extrasBundle.putBinder(EXTRA_SESSION, null);
    intent.putExtras(extrasBundle);

    intent.putExtra(EXTRA_EXIT_ANIMATION_BUNDLE, bundle);
    startActivity(intent);
}

Hope to have helped.

Solution 2:

I stumbled upon the same issue, enter animation working like a charm but couldn't get it working for the exit animations until I realised I might have passed the wrong context to setExitAnimations. Therefore be sure to pass the context of activity from where the custom tab is opened.

Post a Comment for "Exit_animation_bundle Not Working With Chrome Custom Tabs"