我正在尝试阅读应用活动中的通知数据。如果应用已关闭,我会发送通知并打开应用程序onclick。这工作正常,我正在获取数据。我正在onCreate中提取意图。
但我不知道如果应用程序打开我怎么能读取意图。 onNewIntent()不起作用。
if (!NotificationUtils.isAppIsInBackground(getApplicationContext())) {
// app is in foreground, broadcast the push message
Log.e("GROUND", "BACK");
Intent pushNotification = new Intent(AppConfig.PUSH_NOTIFICATION);
pushNotification.putExtra("message", message);
LocalBroadcastManager.getInstance(this).sendBroadcast(pushNotification);
// play notification sound
NotificationUtils notificationUtils = new NotificationUtils(getApplicationContext());
notificationUtils.playNotificationSound();
} else {
// app is in background, show the notification in notification tray
Log.e("GROUND", "FOR");
Intent resultIntent = new Intent(getApplicationContext(), SecurityMainActivity.class);
resultIntent.putExtra("message", message);
}