I have a BroadcastReceiver that launches an Activity . If the Activity starts when the screen is turned on, it is displayed, and everything is in order. However, on ICS and JB devices (I did not test GB or HC, but the problem does not exist with Froyo), if the Activity launched when the screen is off, the lockscreen is not disabled, and the activity is not disabled it displays when the phone is unlocked (or by unlocking manually, or using the code I entered for post Froyo devices).
Why, at least on ICS and JB devices, the screen lock does not turn off without the code mentioned below and why the activity is not displayed if the screen was turned off when the Activity started?
Here is the code:
In BroadcastReceiver :
Intent alarmAlert = new Intent(context, AlarmGoneOffActivity.class); alarmAlert.putExtra(MyAlarmManager.ALARM_NUM_ID, alarm.ID); alarmAlert.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); context.startActivity(alarmAlert);
In AlarmGoneOffActivity.onCreate() :
setContentView(R.layout.alarm_gone_off); final Window win = getWindow(); win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON, WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); }
Edit: I would prefer not to use KeyguardLock.disableKeyguard() , because it locks the key lock until KeyguardLock.reenableKeyguard() , which is inconvenient. Any solutions?
Edit2: Now I can confirm that the problem exists only in ICS and above. Something has changed that interferes with locking the keypad lock? And even if it was, why my Activity not displayed when the screen is unlocked manually?
Eliezer
source share