title: Android Activity Not Showing When Screen is Woken Up and Lock Screen Not Disabling
body: <p>I have a <code>BroadcastReceiver</code> that starts an <code>Activity</code>. If the <code>Activity</code> is started while the screen is on, it displays and everything is fine. However, on ICS and JB devices (I haven't tested GB or HC but the issue doesn't exist with Froyo) if the <code>Activity</code> is started while the screen is off, the lockscreen is not disabled, and the activity is not shown when the phone is unlocked (either through unlocking it manually or with the code I put in for post Froyo devices).</p>
  
  <p>Why, on at least ICS and JB devices, does the lockscreen not get disabled without the mentioned code below, and why doesn't the activity show if the screen was off when the <code>Activity</code> was started?</p>
  
  <p>Here's the code:</p>
  
  <p>In the <code>BroadcastReceiver</code>:</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>In <code>AlarmGoneOffActivity.onCreate()</code>:</p>
  
  <pre><code>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);
  }
  
  //so far all of my post froyo devices (ICS and JB no more GB)
  // don't bypass the lockscreen unless we use this
  if(Build.VERSION.SDK_INT &gt; Build.VERSION_CODES.FROYO) {
      KeyguardManager  myKeyGuard = 
                      (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
      KeyguardLock myLock = myKeyGuard.newKeyguardLock("ShabbosAlarm");
      myLock.disableKeyguard();
  }
  </code></pre>
  
  <p><strong>Edit:</strong> I would really prefer not to use <code>KeyguardLock.disableKeyguard()</code> because it causes the keyguard to become disabled until <code>KeyguardLock.reenableKeyguard()</code> which is inconvenient. Any solutions? </p>
  
  <p><strong>Edit2:</strong> I can now confirm that the issue only exists on ICS and above. Was something changed that prevents the keyguard from being disabled? And even if there was, why is my <code>Activity</code> not showing when the screen is manually unlocked?</p>