我不希望通知管理器(状态栏)打开活动。相反,当通知被点击时,它就会被取消,而且什么都不会发生。我不希望通知管理器打开活动
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. 我希望活动能够在onConfigurationChanged()
- 10. 我希望我的应用处于“打开”浏览器部分
- 11. 我希望在用户登录后开始主要活动
- 12. 通知打开活动,后退按钮被按下,主要活动被打开?
- 13. 通知打开活动,按回按钮,防止打开回栈活动?
- 14. 打开通知活动时点击通知与firebase
- 15. 打开BroadcastReceiver发送的通知时打开活动
- 16. 待定意图不工作,通知不会打开活动
- 17. Facebook分析推送活动 - 应用内通知 - 缺少通知管理器
- 18. 通知打开活动,我需要关闭它后
- 19. 如何重新打开通知中的活动点击我android
- 20. 从通知开始活动
- 21. 通知不在android中开始活动
- 22. 如何不从通知开始活动
- 23. 每次我打开不同的活动时,如何显示不同的通知?
- 24. 手动打开SDK独立管理器
- 25. 根据通知操作点击打开不同的活动
- 26. 如何修复OnConfigurationChanged中的布局,当我不希望重新开始活动
- 27. Apache不希望开始 - XAMPP
- 28. 活动从在活动堆栈顶部打开的通知开始
- 29. Android - 通知管理器
- 30. 活动仍然打开,当收到通知推送时双打
或尝试使用此PendingIntent pendingIntent = PendingIntent.getActivity(this,0,null,0); – MobileEvangelist