问题描述
查看 android 文档,似乎我们无法知道应用程序何时关闭.无论是用户明确提出的还是操作系统自动执行的.
下面是onTerminate()
文档 仅在模拟场景中可用.
public void onTerminate()
因为:API 级别 1
此方法用于模拟进程环境.它永远不会在生产 Android 设备上调用,通过简单地杀死进程来删除进程;没有用户代码(包括这个回调)在这样做时被执行.
当用户关闭应用程序时,有没有人有任何其他方法来报告?
我们需要从试点/可用性的角度了解我们是否需要将其他功能整合到我们未来的生产应用中.
不确定这是否会帮助您...
在我的应用中,我使用 Activity.onDestroy() 来做我需要的清理工作.我有几个活动 - 每个活动都有 onDestroy()
.
这是我最接近做我需要的 - 而且它实际上运行得很好.
Looked at android documentation and it appears that we don't have the ability to know when an app shuts down. Whether it was explicitly by the user or automatically by the operating system.
Below is the onTerminate()
documentation which is only available in the emulated scenario.
public void onTerminate()
Does anyone have any other approaches to report back when the user closes the application?
We need to know from a pilot/usability standpoint if we need to incorporate additional functionality into our future production app.
Not sure whether this is going to help you...
In my app, I'm using Activity.onDestroy() to do the cleanup that I need. I have a couple of activities - and have onDestroy()
in each of them.
This is the closest I got to doing what I needed - and it actually works quite well.
这篇关于您可以跟踪 android 应用程序何时终止吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!