У меня есть GCMIntentService
, где я устанавливаю детали для намерения и все, когда пользователь нажимает на уведомление. Мой фрагмент кода отношение к этим ниже:Intent теряет значения в дополнениях
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(context, CustomTabActivity.class);
if (noteId != null && value != null) {
notificationIntent.putExtra("noteId", noteId);
notificationIntent.putExtra("value", value);
}
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification updateComplete = new NotificationCompat.Builder(context)
.setContentTitle(title)
.setContentText(msg)
.setTicker(title)
.setWhen(System.currentTimeMillis())
.setContentIntent(contentIntent)
.setDefaults(Notification.DEFAULT_SOUND)
.setAutoCancel(true)
.setSmallIcon(R.drawable.icon)
.build();
notificationManager.notify(100, updateComplete);
Когда CustomTabActivity.class
открыт, getExtras()
вызов всегда нуль. Почему я не могу получить ценности от намерения?
Я прочитал следующее за этим и не смог решить:
Pass a String from one Activity to another Activity in Android
Android - how can I send a GCM push notification with instructions of which activity to load?
Вы уверены, что 'if' условие всегда верно? – ChiefTwoPencils
Является ли 'CustomTabActivity' уже запущенным в фоновом режиме, когда отправляется сообщение" notificationIntent "? – Vikram
Если всегда верно, когда я запускал его с точками останова. «CustomTabActivity» иногда находится в фоновом режиме, а иногда нет. Но, несмотря на это, все еще не удается. – KVISH