Я пытаюсь создать уведомление, которое при нажатии вызывает сообщение в моем приложении, а затем, когда пользователь нажимает кнопку «Назад», я хочу, чтобы он возвращался на главный экран.Почему это вызывает новый экземпляр
Проблема в том, что сейчас создается новый экземпляр, и все прежние данные теряются. Что я делаю не так?
NotificationManager nm = (NotificationManager) getSystemService("notification");
Intent intent = new Intent(this, beerwarn.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(beerwarn.class);
stackBuilder.addNextIntent(intent);
PendingIntent pIntent = stackBuilder.getPendingIntent
(0, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentIntent(pIntent)
//Notification noti = new Notification.Builder(this)
.setContentTitle("BAC Level Notice")
.setContentText("Your BAC has dropped below Max Legal BAC")
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pIntent)
.setSmallIcon(R.drawable.beerwarn);
//builder.flags |= Notification.FLAG_AUTO_CANCEL;
nm.notify(1, builder.build());