Milèstre BV
Oct 27, 2021

Xamarin Forms: Android BroadcastReceiver after Reboot


Registered ;ocal notifications get lost when your Android device is rebooted. To reregister those local notifications again when the device is started again, you need a BroadcastReceiver class in your Android project;

[BroadcastReceiver]
[IntentFilter(new[] { Intent.ActionBootCompleted })]
public class NotificationsBootReceiver : BroadcastReceiver
{
  public async override void OnReceive(Context context, Intent intent)
  {
    //define the necessary actions heer
  }
}
And in the manifest:

<receiver android:name=".NotificationsBootReceiver" android:enabled="true" android:exported="true" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>

This is all you need, to make it work. You can define a Toast message in the OnReceive method, to get noticed that the BootReceiver works.

 





About us

Milèstre is a digital development agency based in Maastricht and operating all over the world. Since 2003 we build software solutions together with established companies and great startups. During the years we have developed a process that enables us to transform ideas into meaningful, intelligent and designfull experiences for mobile and web. A process where strategy, design, development and user experience are playing an important rol.

 

Contact us

Milestre BV
Ambyerstraat Zuid 82
6225 AJ Maastricht
Netherlands

Tel: +31(0)43 - 4070780
Email: info@milestre.nl
Recent Posts

© Copyright 2022 - Milestre BV
Top