title: Activity doesn't receive Intent triggered from shortcut when app is running
body: <p>On some versions of Android, an Activity in my app is not always receiving a shortcut triggered Intent.</p>
  
  <p>The app creates a shortcut with an intent intended for a specific Activity (SomeActivity) in the app </p>
  
  <pre><code>Intent shortcutIntent = new Intent(this, SomeActivity.class);
  Intent i = new Intent();
  
  i.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); 
  i.putExtra(Intent.EXTRA_SHORTCUT_NAME, 'shortcut name');
  i.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,Intent.ShortcutIconResource.fromContext(this, R.drawable.icon));
  i.setAction("com.android.launcher.action.INSTALL_SHORTCUT");                                                   sendBroadcast(i);
  </code></pre>
  
  <p>The shortcut is installed as expected. </p>
  
  <p>For a Nexus 5 (4.4.4) and Samsung S5 (4.4.2) and an old Samsung (2.3.6) everything works as expected, namely SomeActivity's onCreate function is called when the shortcut is clicked.</p>
  
  <p>But for other devices e.g. Sony Xperia (4.3) it works as expected if you have previously exited from the app, but if the app is in the background (having previously tasked away from the app by pressing the Home button) then when the shortcut is pressed neither of SomeActivity's onCreate or onNewIntent are called.</p>
  
  <p>I managed to fix the problem by either setting a flag on the intent:</p>
  
  <pre><code>scIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  </code></pre>
  
  <p>or setting the launchMode in the manifest to singleTask. </p>
  
  <p>In both these cases onCreate of SomeActivity is always called irrespective of the state of the app (not running or in background). </p>
  
  <p>But launchModes of standard or singleTop don't work (if the app is in background), the app merely comes to the foreground but SomeActivity's onCreate or onNewIntent are not called. I don't understand why they aren't.  </p>
  
  <p>For the record I originally had no launchMode defined (so defaults to standard) and everything behaved correctly. I believe the problem only surfaced when I updated SDK build tools to:</p>
  
  <ul>
  <li>Android SDK Tools 23.0.2</li>
  <li>Android SDK Platform Tools 20</li>
  <li>Android Build Tools 20</li>
  </ul>