在关机前触发程序 我想在关机时启动我的程序,待我的程序处理完后再关机,这个能做到吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 广播监听这个Intent.ACTION_REQUEST_SHUTDOWN 算了。。伪代码先注册广播。<receiver android:name="xx.xx.xx" > <intent-filter> <action android:name="android.intent.action.ACTION_REQUEST_SHUTDOWN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter></receiver>//BroadcastReceiver类static final String ACTION = "android.intent.action.Intent.ACTION_REQUEST_SHUTDOWN";public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub if (intent.getAction().equals(ACTION)){ //do it } <category android:name="android.intent.category.DEFAULT" />去掉copy错了。 汗。。 注意一点不要在广播里做耗时的工作应该转给service去做比较好 <receiver android:name="xx.xx.xx" > <intent-filter android:priority="1000"> <action android:name="android.intent.action.ACTION_REQUEST_SHUTDOWN" /> </intent-filter></receiver>把广播优先等级设置最高试试。。呵呵。。 请问这个效果如何实现?小白求教! 求 教!急!!! 动态添加Tab,像浏览器选项卡那样的效果怎么实现? android mediaplay 怎么播放 rtsp /http 流媒体? android开发者的春天 Android ExternalStorage的问题。 android用achartengine 如何设置柱体上方字的颜色 ListView滚动加载更多之后覆盖页码 在cardslib的card里怎么画achartengine图表 跨互联网adb调试安卓设备 eclipse下开发android问题? 谁能给我讲一下android里的atts 谢谢了,这是自定义是属性还是系统属性?
先注册广播。<receiver android:name="xx.xx.xx" >
<intent-filter>
<action android:name="android.intent.action.ACTION_REQUEST_SHUTDOWN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>//BroadcastReceiver类
static final String ACTION = "android.intent.action.Intent.ACTION_REQUEST_SHUTDOWN";
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
if (intent.getAction().equals(ACTION)){
//do it
}
<receiver android:name="xx.xx.xx" >
<intent-filter android:priority="1000">
<action android:name="android.intent.action.ACTION_REQUEST_SHUTDOWN" />
</intent-filter>
</receiver>
把广播优先等级设置最高试试。。呵呵。。