像锁屏、解锁这种频繁生成事件的广播接收者
注册广播接收者不是在配置文件中
而是在界面添加代码:
IntentFilter filter = new IntentFilter();
filter.addAction("android.intent.action.SCREEN_ON");
filter.addAction("android.intent.action.SCREEN_OFF");
ScreenReceiver receiver = new ScreenReceiver();//广播
this.registerReceiver(receiver,filter);
并且在onDestroy中解绑
unregisterReceiver(receiver);
receiver = null;