Android puzzle: How to tell if two pendingintent are the same?

Source: Internet
Author: User

============ 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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.