广播接收器在Android设备的情况下关闭和不工作 [英] broadcastreceiver in case of android device switched off and on not working
本文介绍了广播接收器在Android设备的情况下关闭和不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的广播接收机执行时,该设备被关闭,再次开启了一些行动,但他们没有working.These在清单文件中的接收器:
I am using broadcast receivers for performing some action when the device is switched off and switched on again,but they are not working.These are the receivers in manifest file:
<receiver android:name=".ShutdownReceiver" >
<intent-filter>
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.QUICKBOOT_POWEROFF" />
</intent-filter>
</receiver>
<receiver android:name=".RestartReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
这是对应的类:
public class ShutdownReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
Log.d("In","Switched Off");
}
}
public class RestartReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
SecureMessagesActivity.ToDoOnMobileSwitchOn();
Log.d("In","Switched On");
}
}
请帮忙me.Thanks提前。
Please help me.Thanks in advance.
推荐答案
务必请在您的清单中的项值
权限:
Be sure to request the RECEIVE_BOOT_COMPLETED
permission in your manifest:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
这篇关于广播接收器在Android设备的情况下关闭和不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文