android – 如何知道设备断电

前端之家收集整理的这篇文章主要介绍了android – 如何知道设备断电前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在移动设备关闭时做点什么,但我不知道方法是什么;你能告诉我如何检测移动设备是否正在关闭
我知道关于移动重启 android.intent.action.BOOT_COMPLETED的方法,但我找不到类似的断电.

解决方法

http://developer.android.com/reference/android/content/Intent.html#ACTION_SHUTDOWN

public static final String
ACTION_SHUTDOWN

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.

Constant Value:
“android.intent.action.ACTION_SHUTDOWN”

这似乎是这样吗?我只是用Google搜索了你的命令,它出现在标准广播操作列表中.

猜你在找的Android相关文章