I Found some codes for quit an Android application programatically. By calling any one of the following code in onDestroy() will it quit application entirely?
The easiest way I found to quit an application from an activity, without breaking Android's logic and without adding more code in existing activities and passing extras is the following:
public static void quitApplication (Activity currentActivity) {
Intent intent = new Intent (currentActivity, QuitApplicationActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
currentActivity.startActivity (intent);
currentActivity.finish ();
}
the QuitApplicationActivity
being:
public class QuitApplicationActivity extends AppCompatActivity {
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
finish ();
}
}