I am somewhat new to android app development. I was wondering why we use pendingIntent
while creating notifications.
I have read this in the docs(https://developer.android.com/training/notify-user/navigation):
this page describes how you set up a PendingIntent for your notification's action so it creates a fresh task and back stack
However, I can't wrap my head around how a PendingIntent creates a fresh task and back stack.
All help is appreciated. Thank you!!
I was wondering why we use pendingIntent while creating notifications.
Read the PendingIntent documentation. Specifically this bit:
A PendingIntent itself is simply a reference to a token maintained by the system describing the original data used to retrieve it. This means that, even if its owning application's process is killed, the PendingIntent itself will remain usable from other processes that have been given it.
In other words - you use a PendingIntent for a notification because a notification can sit in the user's notification area for an indefinite amount of time, during which your app may have been killed.
However, I can't wrap my head around how a PendingIntent creates a fresh task and back stack.
It doesn't. You do, as explained in the very article you linked.