如何知道设备断电 [英] how to know device is power off

查看:150
本文介绍了如何知道设备断电的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这样做,当移动设备正在关闭一些东西,但我不知道什么是方法;你能告诉我如何检测,如果移动设备正在关闭?
我知道手机重启的方法 android.intent.action.BOOT_COMPLETED ,但我无法找到类似的断电。

I want to do something when the mobile device is closing, but I don't know what is the method; could you tell me how to detect if mobile device is shutting down?
I know the method about mobile restart android.intent.action.BOOT_COMPLETED, but I cannot find similar power off.

推荐答案

<一个href="http://developer.android.com/reference/android/content/Intent.html#ACTION_SHUTDOWN">http://developer.android.com/reference/android/content/Intent.html#ACTION_SHUTDOWN

公共静态最后弦乐   ACTION_SHUTDOWN

public static final String ACTION_SHUTDOWN

自:API级别4广播事件:   设备正在关闭。这是   播放时,该设备是   关闭(完全关闭,不   睡眠)。当广播是   完成后,最终关闭将   继续和所有未保存的数据丢失。   应用程序通常不需要处理   此,由于前台活动   将被暂停为好。这是一个   只能发送保护意图   由系统

Since: API Level 4 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.

常数值:   android.intent.action.ACTION_SHUTDOWN

Constant Value: "android.intent.action.ACTION_SHUTDOWN"

这似乎是吗?我只是用Google搜索你的命令,这是标准的广播操作列表中。 :)

This would appear to be it? I just Googled your command and it was on the Standard Broadcast Actions list. :)

这篇关于如何知道设备断电的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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