我不希望通知管理器(狀態欄)打開活動。相反,當通知被點擊時,它就會被取消,而且什麼都不會發生。我不希望通知管理器打開活動
2
A
回答
4
final NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
final Notification notification = new Notification(R.drawable.icon,"A New Message!",System.currentTimeMillis());
notification.defaults=Notification.FLAG_ONLY_ALERT_ONCE+Notification.FLAG_AUTO_CANCEL;
Intent notificationIntent = new Intent(this, null);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,notificationIntent, 0);
notification.setLatestEventInfo(AndroidNotifications.this, title,message, pendingIntent);
notificationManager.notify(NOTIFICATION_ID, notification);
,而不是傳遞類意圖只是通過爲空或使用intent()默認構造函數。如果有幫助,請致電 。
0
創建一個空的活動,調用finish()
從onCreate()
並將其設置在PendingIntent
中。一個空的(空)一個是不允許的,所以這是你最好的選擇,AFAIK。
4
當您創建PendingIntent
傳遞一個空的意圖new Intent()
PendingIntent pending = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0)
,並設置FLAG_AUTO_CANCEL標誌的通知
notification.flags |= Notification.FLAG_AUTO_CANCEL;
相關問題
- 1. 通知打開文件管理器
- 2. 我希望它被打開
- 3. 打開活動已從通知打開
- 4. 通知不會打開活動
- 5. 通過通知打開現有活動
- 6. 活動未從通知欄中打開
- 7. 無法打開通知點擊活動
- 8. 服務通知打開主要活動
- 9. 忽略通知按鈕打開活動
- 10. 當通知的點擊,打開活動
- 11. 從通知中打開活動
- 12. 點擊通知沒有打開活動
- 13. 從通知中打開活動
- 14. 打開新的活動通知點擊
- 15. 從通知中打開活動-Android
- 16. 我希望活動能夠在onConfigurationChanged()
- 17. 我希望我的應用處於「打開」瀏覽器部分
- 18. 通知管理器
- 19. 我希望在用戶登錄後開始主要活動
- 20. 通知打開活動,按回按鈕,防止打開回棧活動?
- 21. 通知打開活動,後退按鈕被按下,主要活動被打開?
- 22. Android通知PendingIntent每通知點擊打開活動
- 23. 打開通知活動時點擊通知與firebase
- 24. 打開BroadcastReceiver發送的通知時打開活動
- 25. 待定意圖不工作,通知不會打開活動
- 26. Facebook分析推送活動 - 應用內通知 - 缺少通知管理器
- 27. 如何重新打開通知中的活動點擊我android
- 28. 通知打開活動,我需要關閉它後
- 29. 我怎樣才能打開活動時通知點擊
- 30. 我不希望打印#號網址
或嘗試使用此PendingIntent pendingIntent = PendingIntent.getActivity(this,0,null,0); – MobileEvangelist