Android - applicationWillTerminate 等效

标签 android ios terminate

有没有办法判断我的 Android 应用程序何时终止?在 iOS 中,AppDelegate 中有一个方法

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

}

我需要这个,因为我只想在应用程序结束运行时做一些事情,而不是在它进入后台或特定 Activity 结束时做。

提前致谢!

最佳答案

Is there a way to tell when my android app will terminate?

没有。一旦处于后台,您的进程可以随时出于任何原因消失。您不会收到进程即将终止的通知。

I want to do something only when the application will be finished running

Android 中并没有真正的“完成运行”的概念。

关于Android - applicationWillTerminate 等效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24091227/

相关文章:

java - 终止 java 子进程的理想方法是什么? process.destroyForcously() 不会终止我的进程

java - 如何在 Android 中偏移 RecyclerView 的第二列?

android - 如何从广播中执行正在运行的服务的方法?

ios - 为 MSMessage 设置标签或唯一标识符

ios - 在 iOS 8 上获取屏幕尺寸

python - ipython:exit() 语句未按预期工作

c++ - 如何正确销毁窗口?

java - 将 Activity 中的数据获取到 RecyclerView 适配器中?

android - 通过 ADB Android 发送 AT 命令

iphone - iOS PNG 图像旋转 90 度