是否可以分别取消注册BroadcastReceiver操作?
我有两个关于时间和日期的动作。
<action android:name="android.intent.action.DATE_CHANGED" />
<action android:name="android.intent.action.TIME_CHANGED" />
我想根据用户输入在它们之间切换。
mReceiver = new MyReceiver();
filter = new IntentFilter();
filter.addAction(Intent.ACTION_DATE_CHANGED);
filter.addAction(Intent.ACTION_TIME_CHANGED);
registerReceiver(mReceiver, filter);
unregister(mReceiver)取消注册两个操作。
创建多个接收器对象并向不同的过滤器注册是否明智?
是的,可以创建多个接收器对象并分别注册它们。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句