Forum Xamarin.Android


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Android 8+ crash at boot_completed


I am currently developing an Android application and I have a mysterious problem on Android 8 to 9. When I restart my phone, I receive an alert message to warn me of the failure of the application (mainly by the service started during Boot_Completed), but the services of the application are still functional. By my stack trace, I can say that the problem comes from the broadcast receiver that launches any other service.

Unfortunately, I was unable to find a fix to that issue.

Below, you can see my broadcast receiver.

[BroadcastReceiver( Name = "com.parroinfo.SERVICE_STARTUP", Enabled = true, Exported = true, DirectBootAware = true)]
    [IntentFilter(new[] {Intent.ActionBootCompleted, Intent.ActionLockedBootCompleted}, Priority = (int)IntentFilterPriority.HighPriority)]
    class ServiceStartup : BroadcastReceiver
        public override void OnReceive(Context context, Intent intent)
             if (AndroidUtils.isVersionBelow(BuildVersionCodes.O))
                        context.StartService(new Intent(context, -type-));
                        context.StartForegroundService(new Intent(context, -type-));

Below, you can see my declaration on my manifest.

<receiver android:exported="true" android:name="com.parroinfo.SERVICE_STARTUP">
        <action android:name="android.intent.action.BOOT_COMPLETED" />

Below, you can see the stack trace of the problem.

  at (
  at$1200 (
  at$H.handleMessage (
  at android.os.Handler.dispatchMessage (
  at android.os.Looper.loop (
  at (
  at java.lang.reflect.Method.invoke (Native Method)
  at$ (
  at (
Caused by: java.lang.IllegalStateException: 
  at (
  at (
  at android.content.ContextWrapper.startService (
  at com.parroinfo.SERVICE_STARTUP.n_onReceive (Native Method)
  at com.parroinfo.SERVICE_STARTUP.onReceive (
  at (
Sign In or Register to comment.