I'm not sure that you are still looking for answers, given that you yourself provided them. However, if you want to achieve your original goal, you probably want to
- Restore RemoteView whenever time changes (it's just easier)
- Set BroadcastReceiver to catch the ticks of the clock so you know when the time has changed.
So, some code is a bit like this:
class MyCleverThing extends Service (say) {
private static IntentFilter timeChangeIntentFilter;
static {
timeChangeIntentFilter = new IntentFilter();
timeChangeIntentFilter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
timeChangeIntentFilter.addAction(Intent.ACTION_TIME_CHANGED);
}
registerReceiver(timeChangedReceiver, timeChangeIntentFilter);
private final BroadcastReceiver timeChangedReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (action.equals(Intent.ACTION_TIME_CHANGED) ||
action.equals(Intent.ACTION_TIMEZONE_CHANGED))
{
updateWidgets();
}
}
};
source
share