Android launchMode="singleTask" and Intent-filters


Staff member
So I have an Activity A that is defined in the AndroidManifest.xml as defined below:


          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />


This Activity launches a welcome Screen which we will call Activity B.

If you launch the application the Welcome screen is displayed and then once the user is done with it Activity A comes back.

The issue I am having is when I push the "Home" button from the welcome screen I go back to the Home Screen as expected. Now when I reclick on the Application Icon the application won't launch. Instead both my Activity A & B get destroyed. If I click on the icon again then the application relaunches as expected.

Now if I'm on the welcome screen and push the back arrow and reclick on the App icon it launches the application as expected. I don't have to push it twice.

Unfortunately I have to use the launchMode="singleTask" since it is a requirement for integration with another team. I have read the Android API's for Tasks and Back Stacks numerous times. Any pointers or suggestions would be greatly appreciated.

I came across <a href="" rel="nofollow">a blog</a> indicating there is an undocumented bug with using singleTask and intent-filters together but didn't find any official documentation on this.


Launching Activity B like this:

Intent intent = new Intent(context, B.class);
startActivityForResult(intent, CONST_VAR);