Hi
I'm creating a Xamarin Forms app and currently I'm struggling with Android implementation of local notification. What I want to achieve ist that when I tap the notification from my app it gets resumed just like the way it's done from home button and not start all over again. I've read many threads and tried many options but nothing works for me, here's my code:
`Intent intent = new Intent(Application.Context, typeof(MainActivity));
intent.SetFlags(ActivityFlags.ClearTop);
const int pendingIntentId = 0;
PendingIntent pendingIntent = PendingIntent.GetActivity(Application.Context, pendingIntentId, intent, PendingIntentFlags.OneShot);
// Instantiate the builder and set notification elements, including pending intent:
Uri uri = RingtoneManager.GetDefaultUri(RingtoneType.Notification);
Notification.Builder builder = new Notification.Builder(Application.Context).SetContentTitle(title).SetContentText(text).
SetSmallIcon(Resource.Drawable.small).SetSound(uri).SetContentIntent(pendingIntent);
// Build the notification:
Notification notification = builder.Build();
notification.Flags |= NotificationFlags.OngoingEvent;
// Get the notification manager:
NotificationManager notificationManager = Application.Context.GetSystemService(Context.NotificationService) as NotificationManager;
// Publish the notification:
const int notificationId = 0;
notificationManager.Notify(notificationId, notification);`
What am I doing wrong ? Maybe someone has got code for that and could share it ?
Greets,
Maciek