PendingIntent

PendingIntent 可以看作是對intent的包裝,通常通過getActivity,getBroadcast ,getService來得到pendingintent的實例,當前activity並不能馬上啓動它所包含的intent,而是在外部執行 pendingintent時,調用intent的。正由於pendingintent中 保存有當前App的Context,使它賦予外部App一種能力,使得外部App可以如同當前App一樣的執行pendingintent裏的 Intent, 就算在執行時當前App已經不存在了,也能通過存在pendingintent裏的Context照樣執行Intent。另外還可以處理intent執行後的操作。常和alermanger 和notificationmanager一起使用。 
Intent一般是用作Activity、Sercvice、BroadcastReceiver之間傳遞數據,而Pendingintent,一般用在 Notification上,可以理解爲延遲執行的intent,PendingIntent是對Intent一個包裝。 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章