============ Problem Description ============
Make another alarm service,
I'm passing in Class A.
Pendingintent pi_1=pendingintent
. Getbroadcast (context, re_1.getalarm_id (), intent_1, 0);
Amanager.set (Alarmmanager.rtc_wakeup, Notifydate_1, pi_1); To create a reminder service,
I will restore the pendingintent in a class by intent, and then cancel: Amanager.cancel (PI);
Results are always reported: NullPointerException
Excuse me:
1. How to determine whether two pendingintent is the same, if different how to investigate the difference?
============ Solution 1============
What does it mean to "restore pendingintent through intent"?
To cancel, create a pendingintent cancel directly:
pendingintent pi = pendingintent.getbroadcast (context, re_1.getalarm_id (), intent_1, 0); Alarmmanager Alarmmanager = (alarmmanager) context.getsystemservice (Context.alarm_service); AlarmManager.cancel (PI) ;
============ Solution 2============
When you cancel, the pendingintent is the same as when you created it. Like an upstairs cancellation when you create a pendingintent that is the same as when it was created. Include parameters.
Android puzzle: How to tell if two pendingintent are the same?