Search code examples
androidandroid-pendingintent

Android does PendingIntent die after performing action?


A simple question, but I cannot find an answer.

Is Android PendingIntent still alive in system after performing it's action (sendBroadcast, startService etc.)?

If so, what is most efficient way to kill it - with cancel() or put FLAG_ONE_SHOT during creation?


Solution

  • Ok, got it. @CommonsWare is right. When I put FLAG_ONE_SHOT - PendingIntent kills itself after performing an action. But in such case I wasn't able to check if this PendingIntent is registered in system.

    Finally I used myPendingIntent.cancel().