How to exit from your app, or kill it

Get an Activity Manager, and then ask for a package restart:

ActivityManager m_activityManager = (ActivityManager) getSystemService(Activity.ACTIVITY_SERVICE);
m_activityManager.restartPackage(PACKAGE_NAME);

And that’s it, it just works.

I know its not recommended, and that it’s against activities lifecycle, but sometimes it is necessary for your app.

Have fun!

Deja un comentario

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.