特殊的广播接收者(界面注册)
像锁屏、解锁这种频繁生成事件的广播接收者
注册广播接收者不是在配置文件中
而是在界面添加代码:
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;
本文出自 “曾颐楠的播客” 博客,请务必保留此出处http://zengyinan.blog.51cto.com/9524976/1721470