I have a DashClockExtension
that sometimes doesn't update.
It's using a LocalBroadcastReceiver to update the extension similar to http://bit.ly/1e4uMl0. The receiver is registered in the onInitialize()
method:
@Override
protected void onInitialize(boolean isReconnect) {
super.onInitialize(isReconnect);
LocalBroadcastManager broadcastMgr = LocalBroadcastManager.getInstance(this);
if (mDashClockReceiver != null) {
try {
broadcastMgr.unregisterReceiver(mDashClockReceiver);
} catch (Exception ignore) {}
}
mDashClockReceiver = new DashClockUpdateReceiver();
broadcastMgr.registerReceiver(mDashClockReceiver, new IntentFilter(UPDATE_DASHCLOCK));
}
That's how I send the broadcast:
public static void updateDashClock() {
LocalBroadcastManager.getInstance(Application.getContext()).sendBroadcast(new Intent(UPDATE_DASHCLOCK));
}
That's my BroadcastReceiver:
private class DashClockUpdateReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
retrieveDataAndUpdateWidget();
}
}
I noticed that while the broadcast is triggered the receiver doesn't receive the event sometimes.
I tested it by killing my app but that doesn't reproduce the issue so I'm at a loss why this would happen.
Anyone?