检测设备被关闭? [英] Detect the device is shutting down?
问题描述
在我的Android应用程序,我需要做一些动作,如果设备突然关闭。有什么办法来检测设备正在关闭?
广播事件:设备正在关闭。这是广播时 设备被关闭(完全关闭,不睡觉)。一旦 广播结束后,最终的关闭将继续,并且所有 未保存的数据丢失。应用程序通常不需要处理这一点,因为 前台活动将被暂停为好。
这是只能由系统发送一个受保护的意图。
可包括以下额外的:
EXTRA_SHUTDOWN_USERSPACE_ONLY被设置为true,如果此关机仅适用于用户空间的进程一个布尔值。如果没有设置,假设是错误的。
恒值: android.intent.action.ACTION_SHUTDOWN
In my android application i need to do some action if the device is turning off suddenly. Is there any way to detect the device is shutting down?
Broadcast Action: Device is shutting down. This is broadcast when the device is being shut down (completely turned off, not sleeping). Once the broadcast is complete, the final shutdown will proceed and all unsaved data lost. Apps will not normally need to handle this, since the foreground activity will be paused as well.
This is a protected intent that can only be sent by the system.
May include the following extras:
EXTRA_SHUTDOWN_USERSPACE_ONLY a boolean that is set to true if this shutdown is only for userspace processes. If not set, assumed to be false.
Constant Value: "android.intent.action.ACTION_SHUTDOWN"
You have to configure the broadcast receiver to listen for this.
这篇关于检测设备被关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!