1.时区变化:
a.AndroidManifest.xml配置方式
<receiver android:name="com.henry.TimeZoneReceiver"> <intent-filter> <action android:name="android.intent.action.TIMEZONE_CHANGED"/> </intent-filter> </receiver>
b.动态注册广播方式
private BroadcastReceiver TimeZoneReceiver= new BroadcastReceiver(){
//TODO 执行接收到广播的操作
}
IntentFilter filter = new IntentFilter();
filter .addAction("android.intent.action.TIMEZONE_CHANGED");
mContext.registerReceiver(TimeZoneReceiver,filter);
2.日期变化
a.AndroidManifest.xml配置方式
<receiver android:name="com.henry.DateChangedReceiver"> <intent-filter> <action android:name="android.intent.action.DATE_CHANGE"/> </intent-filter> </receiver>
b.动态注册广播方式
private BroadcastReceiver DateChangedReceiver= new BroadcastReceiver(){
//TODO 执行接收到广播的操作
}
IntentFilter filter = new IntentFilter();
filter .addAction("android.intent.action.DATE_CHANGE");
mContext.registerReceiver(DateChangedReceiver,filter);
3.时间变化
a.AndroidManifest.xml配置方式
<receiver android:name="com.henry.TimeSetReceiver"> <intent-filter> <action android:name="android.intent.action.TIME_SET"/> </intent-filter> </receiver>
b.动态注册广播方式
private BroadcastReceiver TimeSetReceiver= new BroadcastReceiver(){
//TODO 执行接收到广播的操作
}
IntentFilter filter = new IntentFilter();
filter .addAction("android.intent.action.TIME_SET");
mContext.registerReceiver(TimeSetReceiver,filter);