Search code examples
androidlaunchandroid-recents

Android - Activity launched from the OS's app recent apps list


When the app is started from the OS's recent list, is there a way to ensure the normal launching activity actually starts or set the launching activity in the Manifest, or even prevent the app from OS launching from history?

i.e.

<category android:name="android.intent.category.(HISTORY)" />

I have an app where the state has to be set through a specific activity sequence so I'd like to ensure this without testing and calling finish() and startActivity() in onCreate() methods.


Solution

  • If you are talking about recent apps, you can use android:excludeFromRecents=["true" | "false"]

    "Whether or not the task initiated by this activity should be excluded from the list of recently used applications ("recent apps"). That is, when this activity is the root activity of a new task, this attribute determines whether the task should not appear in the list of recent apps. "true" if the task should be excluded from the list; "false" if it should be included. The default value is "false". "

    Ref: http://developer.android.com/guide/topics/manifest/activity-element.html