Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Launching application from android local notification

$
0
0

Hello,

I'm trying to launch the application when the user taps a local notification. To accomplish this, we need to set the ContentIntent to the notification, and that start's the desired activity set at the intent.

Here's some code:

Intent mainActivityIntent = new Intent(context, typeof(MainActivity)); PendingIntent mainActivityPendingIntent = PendingIntent.GetActivity(context, 0, mainActivityIntent, PendingIntentFlags.NoCreate); Notification.Builder builder = new Notification.Builder(context) .SetContentTitle("Atenção").SetContentText(texto) .SetSmallIcon(Resource.Drawable.icon); Notification notification = builder.Build(); notification.ContentIntent = mainActivityPendingIntent;

The problem is, when the user taps, if the application is already loaded, a new instance of the application is created. I tried to re-use an instance of the Application but the same problem happens.

Could somebody help me?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>