Having problem receiving broadcast after reboot?
I have a class receiving the broadcast after reboot like this.
[BroadcastReceiver(Enabled = true, Exported = true, Permission = "RECEIVE_BOOT_COMPLETED")]
[IntentFilter(new string[] { Android.Content.Intent.ActionBootCompleted })]
public class StartupBootReceiver : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
var startupIntent = new Intent(Application.Context, typeof(StartupService));
Application.Context.StartService(startupIntent);
}
}
The permission in the manifest has set with Boot_Completed
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
When I used the adb command to send the boot broadcast, the receiver didnt' call the receiver.
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED com.jet.pro
Am I got something missing here?
If you have force stopped the app, your app will not receive anymore
ActionBootCompleted
intents until a user runs your app again or the device is rebooted.This is a malware respawn prevention to allow users and/or Anti-malware services to disable and uninstall the app without chasing a never ending chain of process starts.
Thus if you are debugging and hit "Stop" in the debugger, the app is killed (forced closed).
Without starting your app manually after that reboot:
Assuming some log output like this:
Update: Debug Manifest review:
The only thing that I am manually setting is the
ReceiveBootCompleted
under the required permissions section. The rest is auto-generated based upon the class attributes: