Intent.ACTION_TIME_TICK 广播

代码笔记记录一下。Intent.ACTION_TIME_TICK 广播需要动态注册,不能在清单文件配置.


TimeReceiver mBroadcastReceiver = new TimeReceiver();
IntentFilter intentFilter = new IntentFilter();intentFilter.addAction(Intent.ACTION_TIME_TICK);
registerReceiver(mBroadcastReceiver, intentFilter);

在 TimeReceiver 监听广播接收。

public class TimeReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		if(Intent.ACTION_TIME_TICK.equals(intent.getAction())) {
			//todo...
		}
	}
}


你可能感兴趣的:(Android,笔记)