Question

To exit an app programatically in Android (for instance, if the user presses an exit button), I use:

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

However, the CATEGORY_HOME intent category is not supported when porting Android apps for Playbook or Blackberry 10. What should I use instead?

Was it helpful?

Solution

I think your "exit an app code" for your Android app is quite the opposite of exiting the app: You start a new activity for the home screen instead of finishing "your own" activity.

You should instead finish your activity like this (and consider if that applies to more than one activity on your stack):

myAppView.finish()

This would also "quit" your application on bb10 - which means, it will be minimized and shown as an active frame until you tip on the X to close it.
As well, it would be a good idea to decide if you should clear outstanding notifications at this time (for my app, this makes sense...)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top