Search code examples
javaandroidandroid-5.0-lollipop

How does chrome on android manage to show tabs in task switcher?


Short question: How does (or did) Google Chrome on Android manage to show its tabs in the Android OS task switcher (or "running apps switcher")?

What should I do (preferring Java) to let my app (instances, activities or whatever I need) appear there?


Solution

  • Based on CommonsWares answer I got the following solution:

    Intent i = new Intent(CurrentActivity.this, MultipleInstancesActivity.class)
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NEW_TASK)
    startActivity(i)
    

    The new document flag lets each new task appear in the task switcher. Unfortunately that works only on Android 5.0 (Api 21) and newer versions. I found no way to achieve something like that for Android 4.

    Tips for Android 4 Developers: New Task Flags work - You may implement your own task switcher just for your app. Android provides methods for checking for running tasks and switching between them.