title: Activity starts but isn't visible when the screen is off or locked
body: <p>I'm creating a reminder application, almost everything works, except the activity that is started when the alarm goes off doesn't show up when the screen is off (the phone is in sleep). When the screen is on, seeing the Android's main desktop, and the alarm goes off the activity appears perfectly fine.</p>
  
  <p>I use AlarmManager.setExactAndAllowWhileIdle(RTC_WAKEUP, ...) to set an alarm, which is invoked at a certain time.</p>
  
  <p>This is how I receive the intent from the AlarmManager:</p>
  
  <pre><code>@Override
  public void onReceive(Context context, Intent intent) {
      int alarmId = intent.getIntExtra(Constants.REMINDER_ALARM_ID, 0);
  
      Intent goingOffIntent = new Intent(context, GoingOffActivity.class);
      goingOffIntent.putExtra(Constants.REMINDER_ALARM_ID, alarmId);
  
      context.startActivity(goingOffIntent);
  }
  </code></pre>
  
  <p>And this is the onCreate of the GoingOffActivity:</p>
  
  <pre><code>super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_going_off);
  context = this;
  
  getWindow().setFlags(
          WindowManager.LayoutParams.FLAG_FULLSCREEN |
                  WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
                  WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                  WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
                  WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,
          WindowManager.LayoutParams.FLAG_FULLSCREEN |
                  WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
                  WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                  WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
                  WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
  
  loadData(getIntent());
  </code></pre>
  
  <p>When the screen is off and the alarm goes off these entries created in the log:</p>
  
  <pre><code>18:35:03.593 20113-20113/me.mitulat.myProgram W/MyProgram: onCreate
  18:35:03.661 20113-20113/me.mitulat.myProgram W/MyProgram: onCreate finish
  18:35:03.674 20113-20113/me.mitulat.myProgram W/MyProgram: onPause
  18:35:03.675 20113-20113/me.mitulat.myProgram W/MyProgram: onPause finish
  18:35:03.714 20113-20113/me.mitulat.myProgram W/MyProgram: onStop
  18:35:03.724 20113-20113/me.mitulat.myProgram W/MyProgram: onStop finish
  </code></pre>
  
  <p>The GoingOffActivity finishes immediately.</p>
  
  <p>When the screen is on but it's locked with a pattern this happens:</p>
  
  <pre><code>18:30:00.503 20113-20113/me.mitulat.myProgram W/MyProgram: onCreate
  18:30:00.585 20113-20113/me.mitulat.myProgram W/MyProgram: onCreate finish
  18:30:00.598 20113-20113/me.mitulat.myProgram W/MyProgram: onPause
  18:30:00.599 20113-20113/me.mitulat.myProgram W/MyProgram: onPause finish
  18:30:00.635 20113-20113/me.mitulat.myProgram W/MyProgram: onStop
  18:30:00.655 20113-20113/me.mitulat.myProgram W/MyProgram: onStop finish
  18:30:00.764 20113-20113/me.mitulat.myProgram W/MyProgram: onStop
  18:30:00.769 20113-20113/me.mitulat.myProgram W/MyProgram: onStop finish
  </code></pre>
  
  <p>I am testing on real devices, with a minSdkVersion of 23 set in build.gradle.</p>
  
  <p>What do I do wrong?</p>