Ongoing notifications

Some notifications are used to display a task that is underway and may even include information on progress or state.

Getting ready

If we are going to support Android versions prior to 3.0, we will have to install the Xamarin Support Library v4 NuGet or component into our project.

How to do it...

To show progress in a notification, we can use a progress bar and update the notification as progress is made:

  1. Most ongoing notifications are not going to be dismissed when tapped, so instead of using SetAutoCancel() method, we use SetOngoing() method:
    var notification = new NotificationCompat.Builder(this) .SetSmallIcon(Android.Resource.Drawable.StatNotifySync) .SetContentTitle("Simple Notification") .SetContentText("Starting Work!") ...

Get Xamarin Mobile Development for Android Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.