Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Resume app after notification click

JonAlzaJonAlza ESMember ✭✭✭

I'm developing cross platform app with Xamarin.Forms that show a notification when a timer finishes and the app is not active. I tried using Local Notifications Plugin, but I had problems with shared library reference. So I took the code from github and I use more or less the same code in my app. Now I had another problem: when notification is clicked the launcher activity is launched instead of resume the current activity.

I think that the problem is in LocalNotificationsImplementation class. In Show() method there is this code:

var resultIntent = GetLauncherActivity();
resultIntent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
var stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(Application.Context);
var resultPendingIntent =
    stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);
 _manager.Notify(id, builder.Build());

And this is GetLauncherActivity()

public static Intent GetLauncherActivity()
    var packageName = Application.Context.PackageName;
    return Application.Context.PackageManager.GetLaunchIntentForPackage(packageName);

I can see that this method gets the launcher.

Is it possible to get an Intent to only resume the app to show the current screen?

Best Answer


Sign In or Register to comment.