Я пытаюсь передать значение моего push-уведомления в свою деятельность. Но он всегда возвращает null.Как я могу передать дополнительную строку из Уведомления в действие
Вот как я пытаюсь передать дополнительную строку:
Intent notificationIntent = new Intent(context, Register.class);
notificationIntent.putExtra("NotificationMessage", new_key.toString());
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
// Play default notification sound
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(0, notification);
Вот моя деятельность, где я пытаюсь получить эту дополнительную строку.
Intent intent = getIntent();
String msg = intent.getStringExtra("NotificationMessage");
Toast.makeText(this, "Hello"+msg, Toast.LENGTH_LONG).show();
Этот тост всегда показывают мне "Привет нуль". Кто-нибудь может помочь?
Заранее спасибо.
это не работает для меня ... –
Попробуйте с флагом 'FLAG_ACTIVITY_NEW_TASK' –
Нет же результат NULL –