Search code examples
androidandroid-widgetbroadcastreceiveralarmmanager

Broadcast Receiver and widget timezone


I use Broadcast Receiver, WidgetProvider and Configure Activity. Activity starts during the creation of a widget. Widgets are updated every 20 seconds.

  private PendingIntent service = null; 
   Intent intent = new Intent(context, AlarmReceiver.class);
       if (service == null) {
        service = PendingIntent.getBroadcast(context, 0, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);
    }
        m.setRepeating(AlarmManager.RTC, TIME.getTime().getTime(), 1000 * 20,
            service);

I whant to update widgets when I change time or timezone on my phone. Widgets are updated when I change the time ahead. But when I change the time back, nothing happens. I've already added to the manifest

        <receiver android:name=".AlarmReceiver" >
        <intent-filter>
            <action android:name="android.intent.ACTION_TIMEZONE_CHANGED" />
            <action android:name="android.intent.ACTION_TIME" />
        </intent-filter>
    </receiver>

In the Broadcast Receiver I'm updating widgets.


Solution

  • Please refer to http://developer.android.com/reference/android/content/Intent.html#ACTION_TIMEZONE_CHANGED

    They should be

    <action android:name="android.intent.action.TIMEZONE_CHANGED" />
    <action android:name="android.intent.action.TIME_SET" />