0
我有一個推送通知的Android應用程序。我在使用某些設備時遇到問題,當我發送推送通知時,用戶的應用會自動打開。我不想這樣做。我想讓通知正常顯示,如果用戶點擊它,應用程序將打開。如何停止推送通知自動打開應用程序?
如何防止應用程序自動打開?
這裏是我的意圖的代碼推送通知:
Intent notificationIntent = new Intent(this, MainActivity.class);
notificationIntent.setFlags(
Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(this, requestID, notificationIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
// Display a notification with an icon, message as content, and default sound. It also
// opens the app when the notification is clicked.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setContentTitle(title)
.setContentText(message)
.setColor(0xFF221E80)
.setDefaults(Notification.DEFAULT_SOUND)
.setAutoCancel(true)
.setFullScreenIntent(contentIntent, true)
.setContentIntent(contentIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(
Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, builder.build());
謝謝!我真的不知道那是怎麼被忽視的!現在按預期工作! =) – filipebarretto
沒問題,很高興一切正常,快樂的編碼! – Bobbake4