我正在尝试实现一个广播接收器,该广播接收器在重新启动设备后会广播,但是无法正常工作(当重新启动设备后,它应该向我敬酒),使用以下代码:
广播接收器:
[BroadcastReceiver]
public class RebootReceiver : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
if (Intent.ActionBootCompleted.Equals(intent.Action))
{
Toast.MakeText(
context,
"Your app has been rebooted!",
ToastLength.Long).Show();
}
}
}
Manifest.xml
<receiver android:name=".RebootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"></action>
</intent-filter>
</receiver>
以及清单中的权限
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
希望帮助,谢谢
添加用于启动许可的清单条目