title: Android - Create shortcut from adb
body: <p>I want to create a shortcut via adb for an application I'm developing.</p>
  
  <p>I have looked in <a href="http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/2.1_r2/com/android/launcher/Launcher.java#Launcher.infoFromShortcutIntent%28android.content.Context,android.content.Intent%29" rel="nofollow">Grepcode</a> to see how the intent Android is expecting to be formatted.
  I also checked the <a href="https://developer.android.com/tools/help/adb.html#am" rel="nofollow">AM documentation</a> to try to create the intent required.</p>
  
  <p>So far I got a lot of variations of the line below, but this one seems the most appropriate.</p>
  
  <pre><code>adb -d shell am broadcast \
  -a com.android.launcher.action.INSTALL_SHORTCUT \
  --es Intent.EXTRA_SHORTCUT_NAME "&lt;shortcut-name&gt;" \
  --esn Intent.EXTRA_SHORTCUT_ICON_RESOURCE \
  &lt;package-name&gt;/.activity
  </code></pre>
  
  <p>I have left the <code>EXTRA_SHORTCUT_ICON_RESOURCE</code> null, since Android should search the package itself and use the app_icon defined there.</p>
  
  <p>The command runs and produces</p>
  
  <pre><code>Broadcasting: Intent { act=com.android.launcher.action.INSTALL_SHORTCUT cmp=&lt;package-name&gt;/.activity (has extras) }
  Broadcast completed: result=0
  </code></pre>
  
  <p>No shortcut is added to the main screen, and I suppose it has something to do with the switches of the command.</p>
  
  <p>Anyone has come across anything like this?</p>
  
  <p>Any help greatly appreciated.</p>
  
  <p>-JK</p>