나는 특정 시간과 분이 지날 때까지 울리지 않을 알람이 있습니다. 그러나 그 시간이되면 앱을 다시 시작할 때마다 꺼질 것입니다. 앱이 시작되면 재설정되고 새 알람이 있는지 확인합니다.Android에서 AlarmManager를 취소하는 방법
예를 들어 오전 9:48에 해제됩니다. 9시 48 분 전에 예상대로 아무 일도 일어나지 않습니다. 그러나 9시 48 분 이후에는 앱이 시작될 때마다 계속 진행됩니다 (알람은 간단한 상태 표시 줄 알림입니다).
여기 코드가 있습니다 - 어디서 잘못 되었나요?
는 는는 // 알람 여기에서 설정 -이 코드는 때마다 응용 프로그램을 호출 최대
public void setAlarm() {
for (int i : AlarmDays) {
Calendar cal = Calendar.getInstance();
if (cal.get(Calendar.DAY_OF_MONTH) > i)
cal.add(Calendar.MONTH, 1);
cal.set(Calendar.DAY_OF_MONTH, i);
cal.set(Calendar.HOUR, 9);
cal.set(Calendar.MINUTE, 53);
cal.set(Calendar.SECOND, 1);
String Name = AlarmNames.get(count);
count = 0 + 1;
Intent intent = new Intent(ManageDebts.this, TimeAlarm.class);
Bundle b = new Bundle();
b.putString("keyvalue", Name);
intent.putExtras(b);
pendingIntent = PendingIntent.getBroadcast(this, i,
intent, PendingIntent.FLAG_CANCEL_CURRENT);
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),
pendingIntent);
}
}
내가 무시를 설정하는 TimeAlarm.class
public class TimeAlarm extends BroadcastReceiver {
NotificationManager nm;
@Override
public void onReceive(Context context, Intent intent) {
String DebtName = intent.getStringExtra("keyvalue");
nm = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence from = "Payment Due: " + DebtName;
CharSequence message = "Update your Balance Now";
Intent notificationIntent = new Intent(context, ManageDebts.class);
notificationIntent.getExtras();
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
notificationIntent, 0);
Notification notif = new Notification(R.drawable.icon, "Pay "
+ DebtName + " today!", System.currentTimeMillis());
notif.setLatestEventInfo(context, from, message, contentIntent);
notif.defaults = Notification.DEFAULT_SOUND
| Notification.DEFAULT_LIGHTS;
notif.flags = Notification.FLAG_SHOW_LIGHTS;
notif.ledOnMS = 100;
notif.ledOffMS = 100;
notif.flags |= Notification.FLAG_AUTO_CANCEL;
nm.notify(1, notif);
}
}
과거에 알람을 설정하지 않았는지 확인하십시오 (예 : 9:48 이후 9시 48 분). – CommonsWare
그것이 정확하게 내가하고있는 것처럼 보입니다. 해당 분, 시간 및 초에없는 모든 알람을 무시하도록 설정하려면 어떻게해야합니까? 또는 후에? – KickingLettuce