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. 如何在gwt應用程序重新啓動/關閉之前執行操作?
- 9. 關閉以前打開的面板jQuery
- 10. 關閉之前打開的應用程序
- 11. 無法關閉並重新打開Dojox中的浮動面板
- 12. Android - 通知活動音頻關閉應用程序啓動
- 13. 關閉程序後重新啓動應用程序
- 14. 如何關閉當前打開的應用程序,當點擊推送通知
- 15. 我想打開應用程序後關閉通知
- 16. 應用程序打開和關閉通知
- 17. 通知應用程序被關閉並重新打開與通知後沒有被調用
- 18. 從通知中打開應用程序
- 19. GCM - 從通知打開應用程序?
- 20. 即使應用程序關閉,如何啓動Android通知?
- 21. firebase通知,立即啓動和關閉ios應用程序
- 22. 關閉應用程序並在啓動器上打開
- 23. 單擊通知時從頭開始重新啓動Android應用程序
- 24. 調用重新啓動打開的應用程序的方法
- 25. 如何重新啓動Robotium中關閉的應用程序?
- 26. 應用程序關閉並重新啓動後還原的ImageView
- 27. 在啓動時自動打開在關閉ide之前打開的項目
- 28. 應用程序關閉前/應用程序打開前的Swift iOS 9+
- 29. iPhone應用程序崩潰在關閉/重新打開
- 30. 關閉並重新打開應用程序
我用Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP ..但它是一樣的...打開的活動保持原樣... n新的意圖活動得到歡迎 – CoDe