Quand ma notification se déclenche, je veux restaurer l'activité qui a été mis en arrière-plan, pas commencer une nouvelle activité. J'ai vu des réponses au sujet de l'utilisation FLAGS mais je ne sais pas comment le mettre en œuvreComment restaurer l'activité précédente en cliquant la notification
contentIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | INTENT.FLAG_ACTIVITY_SINGLE_TOP);
Où dois-je mettre dans mon code? J'ai essayé mais ça n'a pas marché. S'il vous plaît aider!
ns = Context.NOTIFICATION_SERVICE;
mNotificationManager = (NotificationManager) getSystemService(ns);
icon = R.drawable.icon;
tickerText = "Short Msg";
when = System.currentTimeMillis();
notification = new Notification(icon, tickerText, when);
context = getApplicationContext();
contentTitle = "MyApp";
contentText = "Reopen App";
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationIntent = new Intent(this, StartTimer.class);
contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);