Reputation: 38682
For Android, we had a very dirty workaround—don't ask, clients—that basically worked like this in the main activity. When quitApp()
is called, the activity stack is cleared and the app exits completely.
public void quitApp() {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("EXIT", true);
startActivity(intent);
}
@Override
public void onResume() {
super.onResume();
if (getIntent().getBooleanExtra("EXIT", false)) {
finish();
}
}
We've now packaged this app for BlackBerry 10, and everything else runs fine, except for this piece of code. What happens when quitApp()
is called is that the activity refreshes (sometimes it goes to the app "exposé" thing in between) but in any case the app stays on-screen.
Is there any other workaround for force-quitting an Android app packaged for BB10?
Upvotes: 0
Views: 167
Reputation: 76506
System.exit(1);
will do it for you.
It is a system hook: http://docs.oracle.com/javase/1.5.0/docs/guide/lang/hook-design.html
Discussed here: When should we call System.exit in Java
Here is the Android Doc : http://developer.android.com/reference/java/lang/System.html#exit(int)
Why you shouldn't use System.Exit in Android is here: Is quitting an application frowned upon?
Upvotes: 1