• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Exit from app

AlexeyS

Newbie
I want to exit from app, i created a menu with option exit, when the user choose exit menu, app shutdown. But unfortunately this not work always. What's wrong? Thank you

i wrote this code on my button EXIT click.

Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("LOGOUT", true);
startActivity(intent);

And in the onCreate() method of MainActivity.class i wrote in the a first line :

if (getIntent().getBooleanExtra("LOGOUT", false))
{
finish();
}
 
Try this

Code:
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(1);
 
Back
Top Bottom