title: Starting activity from service on lock screen turns on the screen but does not show the activity itself
body: <p>I'm trying to start an activity from a service I had already acquired the lock for as follows:</p>
  
  <pre><code>Intent i = new Intent(context, MyActivity.class);
  i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION);
  startActivity(i);
  </code></pre>
  
  <p>The activity manifest is declared as follows:</p>
  
  <pre><code>&lt;activity
          android:name=".MyActivity"
          android:configChanges="orientation|screenSize|keyboardHidden|keyboard|navigation"
          android:excludeFromRecents="true"
          android:launchMode="singleInstance"
          android:screenOrientation="nosensor"
          android:showOnLockScreen="true"
          android:taskAffinity=""
          android:theme="@style/MyTheme" /&gt;
  </code></pre>
  
  <p>And finally, on <code>onCreate()</code> or on <code>onAttachedToWindow()</code> (I tried on both), I add the following flags:</p>
  
  <pre><code>final Window win = getWindow();
  win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
              | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
  win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
              | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
              | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
  </code></pre>
  
  <p>The problem is that the first time I call <code>startActivity()</code> from my service, the screen turns on but the activity itself does not show up. It shows the lock screen instead. Every subsequent call of <code>startActivity()</code> works properly but I can't find a reason for this odd behavior.</p>
  
  <p>I tried already suggestions to get a full wakelock instead of partial, change the flags and values in the manifest according to the following SO answers:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/12979709/android-activity-not-showing-when-screen-is-woken-up-and-lock-screen-not-disabli?rq=1">Android Activity Not Showing When Screen is Woken Up and Lock Screen Not Disabling</a></li>
  <li><a href="https://stackoverflow.com/questions/4352548/how-to-unlock-the-screen-when-broadcastreceiver-is-called?lq=1">how to unlock the screen when BroadcastReceiver is called?</a></li>
  <li><a href="https://stackoverflow.com/questions/9966506/programmatically-turn-screen-on-in-android?rq=1">Programmatically turn screen on in android</a></li>
  <li><a href="https://stackoverflow.com/questions/19003568/android-galaxy-s4-activity-that-is-visible-over-lock-screen?rq=1">Android Galaxy S4 -- Activity that is visible over lock screen</a></li>
  </ul>
  
  <p>Note that my theme is not a dialog but a fullscreen activity.</p>
  
  <p>Any other ideas?</p>