Search code examples
androidandroid-intentlauncher

HOME/LAUNCHER activity messes up activity stack


We are developing a home screen replacement app (a kind of launcher), so our home activity is defined as follows:

<activity android:name="Home"
        ...
        android:launchMode="singleInstance"
        android:stateNotNeeded="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.HOME"/>
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

(see Use my own Android app/apk as launcher/Home Screen Replacement)

This works great, except for the following scenario:

  • User is in Home activity
  • User presses a button to go to activity A
  • User presses the home button (hardware device button), so Home activity is shown again
  • User presses a button to go to activity B
  • User presses the back button

At this point, activity A is shown again.

However, I expect the application to show the home activity. After all, the user went from the home activity to activity B.

What are we doing wrong?


Solution

  • Switching to android:launchMode="singleTask" solved the problem.