簡體   English   中英

我可以在一個通知操作中捆綁多個PendingIntents嗎?

[英]Can I bundle multiple PendingIntents in a Notification Action?

我想在按下操作按鈕時關閉通知,但是我正在使用的PendingIntents不可更改。 我可以將待處理的意圖捆綁在一起,以便可以激發一個意圖,而另一個可以消除我的通知嗎?

細節:

我的通知有3個與之相關的操作按鈕( reply, like, share )。 這些操作按鈕中只有1個( like )具有PendingIntent,該PendingIntent進入我自己的應用程序。

其他2個PendingIntents( reply and share )完全由另一個應用程序接收(並且我無權訪問其原始Intent數據,因為我從其他應用程序的通知中復制了待處理的意圖)

我希望能夠在按下回復和分享操作但當前使用的PendintIntents打開各自的應用程序時關閉通知。 我該怎么辦?

由於PendingIntent實現了Parcelable,因此您應該能夠將PendingIntents存儲在按下按鈕時發送給活動的Intent中。

例如:

Intent intent = new Intent(context, MyClass.class);
Bundle pendingIntentBundle = new Bundle();
pendingIntentBundle.putParcelable("pintent", pendingIntent);
intent.putExtra("pintent", pendingIntentBundle);
PendingIntent pendingIntent = PendingIntent.getBroadcast(spaContext, 0, intent, 0);

然后,在您的MyClass收到捆綁包和待定的意圖后,重新廣播它。

暫無
暫無

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

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