微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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搜索了你的命令,它出现在标准广播操作列表中.

原文地址:https://www.jb51.cc/android/309737.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐