简体   繁体   中英

how to make the home screen application icon always launch the same activity on android

I have an application that has multiple activities in it.

I setup the splash screen to be the activity that gets created and run when a user hits the application icon from the home screen (or device applications screen). I did this using the intent-filter category "android.intent.category.LAUNCHER".

The issue I am having is that if I launch my application and navigate to a different activity than the splash screen, then I hit the device "home" button, then relaunch the application from the application icon it seems like it resumes the activity that I hit the device home button from instead of going through my splash screen activity again.

How can I make it go through the splash screen activity no matter what when I hit the application icon?

Put this in your activity tag in your XML

android:clearTaskOnLaunch = "true"

Whether or not all activities will be removed from the task, except for the root activity, whenever it is re-launched from the home screen — "true" if the task is always stripped down to its root activity, and "false" if not. The default value is "false". This attribute is meaningful only for activities that start a new task (the root activity); it's ignored for all other activities in the task. When the value is "true", every time users start the task again, they are brought to its root activity regardless of what they were last doing in the task and regardless of whether they used the Back or Home button to leave it. When the value is "false", the task may be cleared of activities in some situations (see the alwaysRetainTaskState attribute), but not always.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM