我正在使用Service
和BroadcastReceiver
更改锁定屏幕。
它将原生锁定屏幕完全改为自定义,但我无法再次更改为原生。我该怎么做?我应该以某种方式禁用Service
或BroadcastReceiver
?
Service
if(isMustBeLocked) {
IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
mReceiver = new LockScreenReceiver();
registerReceiver(mReceiver, filter);
super.onCreate();
}
code within BroadcastReciever
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
if(!LockScreenService.isMustBeLocked) {
// need to do something here
}
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
Intent intent11 = new Intent(context,LockScreenActivity.class);
intent11.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
} else if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
}
}