Siruk Viktor
Siruk Viktor

Reputation: 514

Android AlarmManager. How to take into account the transition between time zones, and transition to winter and summer time?

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.

Upvotes: 4

Views: 1171

Answers (1)

Deepak Bala
Deepak Bala

Reputation: 11185

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.

Upvotes: 6

Related Questions