Reputation: 577
Returning from a push-notification, my Xamarin android App won't show the content of my Page.
Reproducing:
The app starts as expected. However, after starting it's supposed to display my start page (a simple ContentPage with a WebView) - but nothing is shown. Debugging, I can see that my page is loaded (OnAppearing is called). Starting the app "minimized" usually works - just not when clicking from a notification!
Code for when the app recieves a notification (please tell me if other code is more relevant!):
var intent = new Intent(this, typeof(MainActivity));
intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);
var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.UpdateCurrent);
var notificationBuilder = new Notification.Builder(this)
.SetSmallIcon(Resource.Drawable.testicon)
.SetContentTitle("Test")
.SetContentText(messageBody)
.SetAutoCancel(true)
.SetContentIntent(pendingIntent)
.SetVisibility(NotificationVisibility.Public)
.SetPriority((int)Android.App.NotificationPriority.High);
var notificationManager = NotificationManager.FromContext(this);
notificationManager.Notify(0, notificationBuilder.Build());
Any help to point me in any direction is appreciated!
Upvotes: 2
Views: 505
Reputation: 10831
The app starts as expected. However, after starting it's supposed to display my start page (a simple ContentPage with a WebView) - but nothing is shown.
If you need your Forms app to start from the beginning, you need to comment out/remove intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);
. This flag will restore the existing running app instead of running a new instance of your app.
Upvotes: 1