Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kill all activities when HOME key is pressed android

Tags:

android

I have an app which has 4 activities in it.Within app, history activities, i.e. Activities from where I navigated should not be destroyed , so I don't call finish() when I am navigating.

But when I press HOME button I want to kill all activities , So that When I come back to the app , Index screen or say first activity is displayed instead of previous paused activity.

Problem here seems to be, how to differentiate between backs within an app to HOME button.

I saw few answers regarding this in other questions. Got more confused.
Is there a way other than intercepting HOME KEY PRESS, because as suggested in other threads,
I should not override HOME key press (as it might have side effects)

like image 965
sat Avatar asked Mar 15 '11 06:03

sat


1 Answers

Set android:clearTaskOnlaunch="true" on the activity launched from the home screen.

You might also check some of the other attributes you can specify on activity, to tweak it's behavior a bit more.

like image 75
Franci Penov Avatar answered Oct 28 '22 17:10

Franci Penov