问题
To cancel an alarm, I use alarmManager.cancel(pendingIntent);
which, according to android developers Removes any alarms with a matching Intent. Any alarm, of any type, whose Intent matches this one (as defined by filterEquals(Intent)), will be canceled.
If it compares 2 pendingIntents which are constructed with a different context and the intents they use have a different context as well, but the classes they refer to are the same, does filterEquals(Intent) return true?
So, pendingIntent1 has: context1 and an intent with context1 and class1.class
And pendingIntent2 has: context2 and an intent with context2 and class1.class
Thanks in advance!
回答1:
I think they should be the same. According to this, the context is only needed to retrieve the package name of your application.
来源:https://stackoverflow.com/questions/13787006/android-does-context-affect-filterequals-used-to-cancel-alarm