FLAGCANCELCURRENT
FLAG_CANCEL_CURRENT is a constant defined in the android.app.PendingIntent class. It indicates that when creating a new PendingIntent, any existing PendingIntent that matches the requested Intent will be canceled before the new one is created. This guarantees that the newly created PendingIntent is the one that will be delivered, and that older, potentially stale intents do not fire.
Usage: You typically specify this flag when you call PendingIntent.getActivity, PendingIntent.getService, or PendingIntent.getBroadcast. If a PendingIntent
When to use: Use FLAG_CANCEL_CURRENT when you need to ensure the latest Intent payload is used and
Differences: FLAG_UPDATE_CURRENT updates the extras of the existing PendingIntent instead of canceling it. FLAG_NO_CREATE returns null
Example: PendingIntent pi = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
Notes: The exact behavior can depend on the matching criteria of the Intent (action, data, type, class,