취소를 실행하는 코드가 알람의 발신자 일 필요는 없습니다. 코드는 경보를 생성 한 PendingIntent를 식별하여 취소 할 경보를 식별합니다. 다음과 같이 원본 PendingIntent
의 팩시밀리를 '제조'할 수 있습니다. . .
String pname = this.getPackageName();
// manufacture an appropriate context
Context mycontext = null;
try {
mycontext = createPackageContext(pname,CONTEXT_IGNORE_SECURITY);
} catch (NameNotFoundException e) {
// handle exception here
e.printStackTrace();
}
// and generate a pendingintent
PendingIntent pi = PendingIntent.getService(mycontext,
0, new Intent(mycontext, myalarmreceiver.class), 0);
// Now use alarmmanager to terminate the alarm
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
am.cancel(pi);
이 상황에서 작동하지 않을 수 있지만,이 방법을 시도하지 않은 경우, 그것은 시작하는 좋은 장소가 될 수 있습니다!