Is it possible to get close/exit event of an application?
是的,你可以在LauncherActivity内部你可以重写onDestroy这个方法将在应用程序退出时被调用.
How can i finish an application as whole(By finishing all its applications)?
我相信你想在这里停止你所有的活动.这可以通过多种方式实现.
android.os.Process.killProcess(android.os.Process.myPid());
要么
Intent intent = new Intent(getApplicationContext(),YourHomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
这将清除所有活动,并将使用户进入HomeActivity.在调用它时,您可以在意图中添加一个标志,并使用该值可以完成HomeActivity.使用finish()方法来完成活动.
How to launch an application without having any history of prevIoUs
launch?
您可以使用上述相同的解决方案来实现这一点.第二个.
希望这将有所帮助.
在应用程序类中有一个onTerminate方法,但这不能在生产环境中使用.查看更多关于这个here