3
특정 시간에 2 개의 반복 알람을 취소하고 싶지만 현재 앱이 알람을 생성하자마자 취소를 호출하기로 결정했습니다. 예를 들어 13:18에 반복을 끝낼 시간을 설정하면 반복되는 알람은 그 시간이 될 때까지 반복되어야합니다.특정 시간에 알람 반복 취소
여기에 내가 함께 놀 된 코드의 일부입니다 :
Toast.makeText(this, "Alarm Scheduled for " + midnight, Toast.LENGTH_LONG).show();
AlarmManager Databackon = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Databackon.set(AlarmManager.RTC_WAKEUP,midnight, stoprepeat(V));
// Databackon.set(AlarmManager.RTC_WAKEUP,midnight, PendingIntent.getBroadcast(this,4, intent, PendingIntent.FLAG_UPDATE_CURRENT));
Toast.makeText(this, "THIS " + midnight, Toast.LENGTH_LONG).show();
/*
Button button1=(Button)findViewById(R.id.startupdates);
button1.setVisibility(View.INVISIBLE);
Button button2=(Button)findViewById(R.id.stopbutton);
button2.setVisibility(View.VISIBLE);
*/
}
public PendingIntent stoprepeat(View V)
{
Intent intent = new Intent(UpdatesActivity.this,AlarmReciever.class);
PendingIntent pendingIntent =
PendingIntent.getBroadcast(this,1, intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.cancel(pendingIntent);
Intent intent2 = new Intent(UpdatesActivity.this,DataOff.class);
PendingIntent pendingIntent2 =
PendingIntent.getBroadcast(this,2, intent2,PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am2 = (AlarmManager) getSystemService(ALARM_SERVICE);
am2.cancel(pendingIntent2);
Toast.makeText(this, "Repeating Alarm stopped", Toast.LENGTH_LONG).show();
Button button1=(Button)findViewById(R.id.startupdates);
button1.setVisibility(View.VISIBLE);
Button button2=(Button)findViewById(R.id.stopbutton);
button2.setVisibility(View.INVISIBLE);
return pendingIntent;
}
EPICNESS이게 얼마나 도움이되었는지 전혀 모르겠군요. 정말 고맙습니다. – user3668879
좋은 답변입니다. 많은 도움이되었습니다. :) – Yeahia2508