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:
Most ongoing notifications are not going to be dismissed when tapped, so instead of using
SetAutoCancel()
method, we useSetOngoing()
method:var notification = new NotificationCompat.Builder(this) .SetSmallIcon(Android.Resource.Drawable.StatNotifySync) .SetContentTitle("Simple Notification") .SetContentText("Starting Work!") .SetOngoing(true);
We can also have a progress bar in the notification. This could be indeterminate:
notification.SetProgress(0, 0, true);
Or the progress bar could display a specific value:
notification.SetProgress(100, 27, false);
We can update...