在android中处理手机关机事件 [英] handling phone shutdown event in android

查看:435
本文介绍了在android中处理手机关机事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你可以发布一个简单的代码来处理关机事件。
我需要清单和接收器。



我需要以下内容:
我有一个服务在后台运行,我想检测手机关机为了使其处于静音模式,所以可怕的操作员音乐不会播放。



重新启动手机后(我已经在启动接收器上),服务将启用手机

解决方案

您需要在接收者中收听以下意图操作:

 < action android:name =android.intent.action.ACTION_SHUTDOWN/> 

为了使其与一些提供快速断电功能的HTC(或其他)设备兼容,您可以需要在同一意​​图过滤器中包含以下操作:

 < action android:name =android.intent .action.QUICKBOOT_POWEROFF/> 

有关更多信息,请阅读这个


Could you post a simple code to handle shutdown event. I need manifest and receiver.

I need the following: I have a service running in background and I want to detect phone shutting down in order to make it in silent mode so that the terrible operator music doesn't play.

After restarting the phone (I already have on boot receiver) the service will enable phone sound.

解决方案

You need to listen for the following intent action in your receiver:

<action android:name="android.intent.action.ACTION_SHUTDOWN" />

To make it compatible with some HTC (or other) devices which offer quick power-off feature, you need to include the following action too with in the same intent-filter:

<action android:name="android.intent.action.QUICKBOOT_POWEROFF" />

For more info, read this

这篇关于在android中处理手机关机事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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