У меня есть программа, в которой я вызываю уведомление.Уведомление, если вы его опускаете, запускает новое действие.
mNotificationManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.stat_sys_secure_green;
CharSequence tickerText = "Browser Security Enabled";
long when = System.currentTimeMillis();
notification = new Notification(icon, tickerText, when);
Context context = getApplicationContext();
CharSequence contentTitle = "Browser Security";
CharSequence contentText = "Security Vulnerability Detected";
Intent notificationIntent = new Intent(this, PrivacyMessage.class);
//Test Extra
notificationIntent.putExtra("Primary Key", "Primary Text");
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(HELLO_ID, notification);
Проблема появляется позже в коде, когда я хочу обновить вторичное действие.Основным видом деятельности должна быть возможность динамически изменять дополнения в нем.Я попытался сделать это, запустив новое намерение.
CharSequence contentTitle = "Browser Security";
CharSequence contentText = "Test New Notification";
Intent intent = new Intent(this, PrivacyMessage.class);
notification.icon = R.drawable.stat_sys_secure_orange;
intent.putExtra("Test Thing", "Test Value");
//intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent cI = PendingIntent.getActivity(this, 0, intent, 0);
notification.setLatestEventInfo(getApplicationContext(), "New Title", "NewText", cI);
mNotificationManager.notify(HELLO_ID, notification);
Теперь, когда я выполняю этот код, появляется новый заголовок уведомления, цвет значка меняется, и раскрывающийся список отражает новый заголовок и информацию о добавлении.Однако, когда я нажимаю на него, он не запускает действие с новым намерением.Вместо этого он просто вытаскивает старые действия со старыми дополнениями.Я пробовал и FLAG_ACTIVITY_CLEAR_TOP, и FLAG_ACTIVITY_NEW_TASK, но ни один из них не может очистить старую вторичную активность и создать новую.Есть идеи, как мне это сделать?