안녕하세요.
알람등록을 한 후 시스템 시간을 변경 하면 알람이 울리질 않습니다.
두가지 상황 중에 한가지가 발생을 하고 있습니다.
상황 1)
현재 시간 보다 5분 후 로 알람을 설정 한뒤 시스템설정 시간을 현재 시간보다 10분 늦게 맞춘다. (알람 작동 O)
상황 2)
현재 시간보다 5분 전으로 알람을 설정 한뒤 시스템설정 시간을 알람시간보다 10분 전으로 맞춘다. (알람 작동X)
이부분에 대해서는 도대체 어떻게 처리를 해줘야 할지 고수분들의 답변 기다겠습니다 ㅠㅠ
---------작성 소스---------------------------------------------------------------------------
long alarmTime = (hour * 60 * 60 * 1000) + (min * 60 * 1000);
long currentTime = (cHour * 60 * 60 * 1000) + (cMin * 60 * 1000) + (cSec * 1000);
long firstTime = 0;
long t = 0;
if(currentTime > alarmTime){
t = currentTime - alarmTime;
firstTime = DAY - t;
}else {
t = alarmTime - currentTime;
firstTime = DAY - t;
}
alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
today.setTime(SystemClock.elapsedRealtime() + firstTime);
Intent intent = new Intent(mContext, AlarmService.class);
pi = PendingIntent.getService(mContext, id , intent, 0);
alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, today.getTime(), AlarmManager.INTERVAL_DAY, pi);
벌써 서른이라니..




질문을 에매하게 해버렸네요
질문의 요지는 이렇습니다.
-등록된 알람의 시간값과 시스템시간 값이 서로 달라지면 어떻게 비교를 해야 하는가?
자답입니다 ㅠㅠ
Manifest에 있는 BroadcastReceiver 에 intentfilter를 추가해 줍니다.
<action android:name="android.intent.action.TIME_SET"/>
<action android:name="android.intent.action.TIME_CHANGED"/>
두줄이면 해결 되는군요....