4

Faced with this problem - I need to organize a notice (notification) that will check on a certain day of the week, hour, and minute (eg every Friday at 17:00 - 17:59). Wanted to use the repeat interval 7 * AlarmManaget.INTERVAL_DAY = 604800000 ms.But there was a catch associated to the fact that the user can travel between time zones, and how to solve the problem of transition from summer to winter. In the transition between the time zone (for example in the transition from two to three) belts notification does not appear at 17:00 and at 18:00. I hope for your help.

Siruk Viktor
  • 504
  • 1
  • 8
  • 30

1 Answers1

6

Register a 'timezone changed' broadcast receiver

<receiver android:name=".TimeZoneBroadcastReceiver">
    <intent-filter>
        <action android:name="android.intent.action.TIMEZONE_CHANGED " />
    </intent-filter>
</receiver>

On the onReceive method cancel all your pending alarms and reschedule them.

Deepak Bala
  • 11,095
  • 2
  • 38
  • 49
  • Thanks - but this not solved problem with transition to winter and summer time. I solved this used period AlarmManager.INTERVAL_HOUR with multiple checks in my reciever. P.S. my eng. so (very) bad - sorry. – Siruk Viktor Mar 29 '13 at 14:03
  • I'm not sure I understood that. Registering a timezone receiver should have done the trick. Of course it is possible that I misunderstood when you meant by summer / winter time. Please feel free to add your own answer and accept it. That will benefit the others that read this question. Please also tell us what you meant by summer / winter time. – Deepak Bala Mar 29 '13 at 15:16
  • Alarms are based on UTC time and should not be affected by daylight savings time. [There is a related post on SO discussing that](http://stackoverflow.com/questions/11650486/android-alarmmanager-and-dst-timezone-time-change) – Deepak Bala Apr 02 '13 at 08:52
  • 1
    Thanks for the info - if I understand the article, which is the link above, if I Introduction interval of 6 hours, and this gap will translate the clock 1 hour ahead - that my range is not automatically reduced by 1 hour, that is going to work on 1 hour later the planning of time. Do I understand correctly? – Siruk Viktor Apr 02 '13 at 11:37