views:

47

answers:

2

Hello friends, I want to implement a Home button in my Android App which will terminate the all the Activities but the first one. Instead of user pressing the Back button again and again, I want to give user a single button which will take him/her on the first (Home) Activity. Please help how to implement it.

+1  A: 

I dont have the SDK on this laptop to be sure about the syntax, but i think this is it.

Set up a listener for the "home" button, in the onClick() method:

Intent i = new Intent(ActivityYouAreOnNow.this,firstActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
blindstuff
Thank you buddy.
Mudassir
+1  A: 

Have a look here: http://stackoverflow.com/questions/2776830/android-moving-back-to-first-activity-on-button-click

SteD
Thank you very much buddy. It is exactly what I was looking for. :-)
Mudassir
@Mudassir - Do mark it as 'answered' if this is what you're looking for :-)
SteD