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性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...