简体   繁体   English

我怎么知道该应用程序已在android中完成?

[英]how do i know that app finished in android?

I hope to control app destroy. 我希望控制应用程序销毁。

I know that apps are generated through zygote. 我知道应用程序是通过合子生成的。 So if I want to control when app generated, I can do it using custom zygote. 因此,如果我想控制应用生成的时间,则可以使用自定义合子。

However how do I know app finish? 但是,我怎么知道应用程序完成? There are many case like fore, normal, abnormal and shutdown. 有很多情况,如前,正常,异常和关闭。

Is there a process that runs when all apps are shut down, like all apps are created via zygote? 当所有应用程序都关闭时(例如所有应用程序都是通过合子创建的),是否有运行的进程?

In some case, finishAffinity() , finishAndRemoveTask() and finish() functions are used to finish the app. 在某些情况下, finishAffinity()finishAndRemoveTask()finish()函数用于完成应用程序。 At that time what is process to handle these functions? 那时处理这些功能的流程是什么?

You will need to understand Android Activity Lifecycle for this, check this official document . 为此,您需要了解Android Activity Lifecycle ,请查看此官方文档

This method will be called after activity finish() , so you can override this method and do anything you want: 在activity finish()之后将调用此方法,因此您可以覆盖此方法并执行任何您想做的事情:

@Override
public void onDestroy() {
    super.onDestroy();
    // Do stuff you want here
}

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM