簡體   English   中英

從通知中的待定意圖啟動啟動器活動

[英]Launching launcher activity from pending intent in notifications

如果我的啟動器活動A現在正在運行。

並且一些活動在活動A之上。

例如,這是我的后台ABC

在按通知啟動A,清除ABC,然后打開A,或關閉B和C並通過onNewIntent恢復A時,我需要

我嘗試添加一些標志,但沒有幫助!

 private void push(NotificationModel model, Intent intent) {

    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    //here I'm trying to add flags to my intent
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

在清單文件中使用android:launchMode="singleTop"

它能做什么:

在這種啟動模式下,如果活動的實例已經存在於當前任務的頂部,則不會創建新實例,Android系統將通過onNewIntent()路由意圖信息。

如果任務頂部沒有實例,則將創建一個新實例。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM