您可以追踪Android应用程式何时终止? [英] Can you track when an android application has been terminated?

查看:118
本文介绍了您可以追踪Android应用程式何时终止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看了android文档,看来我们没有能力知道应用何时关闭.无论是由用户明确显示还是由操作系统自动显示.

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.

下面是 onTerminate()文档仅在模拟场景中可用.

Below is the onTerminate() documentation which is only available in the emulated scenario.

public void onTerminate()

因为:API级别1

Since: API Level 1

此方法用于仿真过程 环境.永远不会在生产型Android设备上调用它, 通过简单地杀死进程来删除进程;没有用户代码 (包括此回调)在执行时执行.

This method is for use in emulated process environments. It will never be called on a production Android device, where processes are removed by simply killing them; no user code (including this callback) is executed when doing so.

在用户关闭应用程序时,是否还有其他方法可以进行报告?

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...

在我的应用中,我正在使用活动. onDestroy()进行我需要的清理.我有几个活动-每个活动都有onDestroy().

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应用程式何时终止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆