通知の 1 つがクリアされたことを検出しようとしています (個別にスワイプするか、[すべて削除] 通知ボタンを使用して)。AlarmManager アラームを閉じようとしていますが、これまでのところうまくいきません。コードの何が問題になっていますか?
onCreate(Bundle savedInstanceState) {
...
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notif = new Notification(R.drawable.flag_red_large, reminderName, System.currentTimeMillis());
notif.deleteIntent = PendingIntent.getService(this, notifID, new Intent(this, CleanUpIntent.class), 0);
//Destroy the activity/notification.
finish();
}
class CleanUpIntent extends IntentService {
public CleanUpIntent() {
super("CleanUpIntent");
}
@Override
protected void onHandleIntent(Intent arg0) {
System.out.println(">>>>>>>>>>>>>>>>>>>" + "Repeating Alarm Cancelled...");
Intent i = new Intent("com.utilityapps.YouForgotWhat.DisplayReminderNotification");
int reminderID = i.getExtras().getInt("reminderID");
PendingIntent displayIntent = PendingIntent.getBroadcast(this, reminderID, i, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager alarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
alarmManager.cancel(displayIntent);
displayIntent.cancel();
}
}
}
ご覧のとおりSystem.out.println()
、サブクラスに a を投げて、コードがそのクラスに到達しているかどうかを確認しました。LogCat 出力にその行が表示されないので、何らかの理由で私のPendingIntent.getService()
行が機能していないと推測しています。この問題を解決するにはどうすればよいですか? ありがとう!:D