Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to close all underlying Activities
    text
    copied!<p>I have a notification sending if my app gets new information.</p> <p>But when I click on the notification it re-opens the activity.</p> <p>I have only one activity running, so is there a way to close all other activities from the same app, so I just put that in the oncreate and he's gone..</p> <p>The problem is that there's a timer event that should keep on going while the app is not on top, but everytime I create a new activity, a new timer is created, so the same notification gets send twice making me get allerted two times everytime I get new info..</p> <p>This is where I create my notification, I guess I have to search it in there, for example the "cleartop" or "singletop" I saw googling but did not work..</p> <pre><code> Intent resultIntent = new Intent(this, typeof(QuestionsSession)); resultIntent.PutExtra ("targeturl", targeturl); //resultIntent.SetFlags(ActivityFlags.NewTask | ActivityFlags.SingleTop); resultIntent.SetFlags (ActivityFlags.ClearTop); TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this); stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(QuestionsSession))); stackBuilder.AddNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent); // Build the notification NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .SetAutoCancel(true) // dismiss the notification from the notification area when the user clicks on it .SetContentIntent(resultPendingIntent) // start up this activity when the user clicks the intent. .SetContentTitle("Button Clicked") // Set the title .SetNumber(TagsCount) // Display the count in the Content Info .SetSmallIcon(Resource.Drawable.Icon) // This is the icon to display //.SetContentText(Java.Lang.String.Format("There are {0} new questions.",TagsCount)); // the message to display. .SetContentText(string.Format("There are new questions.")); // the message to display. NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); builder.SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification)); Vibrator v = (Vibrator)GetSystemService (Context.VibratorService); // Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); // Vibrate for 500 milliseconds v.Vibrate(1000); // Finally publish the notification NotificationManager notificationManager = (NotificationManager)GetSystemService(Context.NotificationService); notificationManager.Notify(1000, builder.Build()); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload