0
A
回答
0
使用必须使用一些标志,这可能会帮助ü
Intent notificationIntent = new Intent(context, MainActivity.class);
// set intent so it does not start a new activity
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
// Play default notification sound
notification.defaults |= Notification.DEFAULT_SOUND;
// Vibrate if vibrate is enabled
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(0, notification);
还要检查你的清单上从通知启动活动
android:launchMode="singleTop"
属性。
1
当您创建Intent
来启动您的应用程序时,只需添加Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK
即可。
注:但是,这只有在你的根Activity
仍然存在于任务(即工作:在你的任务在开始任何其他Activity
当你没有调用它的finish()
相关问题
- 1. CountDownTimer在关闭并重新打开应用程序后重新启动
- 2. WPF关闭应用程序并重新打开当前窗口
- 3. 将重新启动应用程序重新启动前面
- 4. 在不同页面关闭/重新打开iPhone应用程序
- 5. 启动关闭iOS应用程序从本地通知
- 6. 获取Mac应用程序的关机/重新启动通知
- 7. WiX卸载 - 在重新启动管理器之前关闭应用程序
- 8. 关闭以前打开的面板jQuery
- 9. 无法关闭并重新打开Dojox中的浮动面板
- 10. Android - 通知活动音频关闭应用程序启动
- 11. 关闭程序后重新启动应用程序
- 12. 如何关闭当前打开的应用程序,当点击推送通知
- 13. 应用程序打开和关闭通知
- 14. 我想打开应用程序后关闭通知
- 15. 通知应用程序被关闭并重新打开与通知后没有被调用
- 16. 从通知中打开应用程序
- 17. 即使应用程序关闭,如何启动Android通知?
- 18. firebase通知,立即启动和关闭ios应用程序
- 19. 关闭应用程序并在启动器上打开
- 20. 单击通知时从头开始重新启动Android应用程序
- 21. 调用重新启动打开的应用程序的方法
- 22. 应用程序关闭并重新启动后还原的ImageView
- 23. 如何重新启动Robotium中关闭的应用程序?
- 24. 应用程序关闭前/应用程序打开前的Swift iOS 9+
- 25. 关闭并重新打开应用程序
- 26. Android应用程序关闭并重新打开时崩溃
- 27. 应用程序在关闭后不会重新打开
- 28. Android:应用程序在关闭并重新打开后崩溃
- 29. iPhone应用程序崩溃在关闭/重新打开
- 30. Word应用程序关闭并重新打开
我用Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP ..但它是一样的...打开的活动保持原样... n新的意图活动得到欢迎 – CoDe