Friday, August 6, 2010

finish the application

AIM : To exit the application from any of the activity of the application.

Solution:
Let assume your root activity is "My_root. j a va "

 Step 1) Create intent to goto your very first activity as follows:

Intent exit_intent=new Intent(this,My_root.class);
exit_intent.set Flags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
exit_intent.putExtra("EXIT", true);    // just value to indicate i want to  exit the application
start Activity(exit_intent);

step 2) Add these lines in your Myroot.java

if (get Intent().getBooleanExtra("EXIT", false)) {
finish();
}



END 
By this way you can exit the application.

No comments:

Post a Comment

Android Developers Blog

Ram's shared items

Amazon Product Ads