I want to close my application, so that it no longer runs in the background.
How to do that? Is this good practice on Android platform?
If I rely on the \"ba
Just write this code on your 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 your MainActivity.class write below code as a first line,
if (getIntent().getBooleanExtra("LOGOUT", false))
{
finish();
}