//use these intent filter
s_intentFilter = new IntentFilter();
s_intentFilter.addAction(Intent.ACTION_TIME_TICK);
s_intentFilter.addAction(Intent.ACTION_TIME_CHANGED);
}
// реализовать трансляцию:
private final BroadcastReceiver m_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_TICK)) {
// your work
}
}
};
// зарегистрировать получателя:
public void onCreate()/onResume {
super.onCreate();
registerReceiver(m_timeChangedReceiver, s_intentFilter);
}
// и отменить регистрацию:
public void onDestroy()/onPause {
super.onDestroy();
unregisterReceiver(m_timeChangedReceiver);
}