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();
}
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();
}