0

I am trying to generate a shortcut using this approach.

However, I noticed that my Galaxy S4 does not have a button for adding a shortcut to the home screen (when I long-tap, the only options are "Set Wallpaper", "Apps and Widgets" and "Folder".

Thus, there seems to be no GUI way to invoke android.intent.action.CREATE_SHORTCUT. I can do it from adb manually using adb, but that will not feasible for non-developer users.

adb shell am start -a android.intent.action.CREATE_SHORTCUT

Is there a different Intent I can listen for instead to work around this problem and create shortcuts anyways?

Community
  • 1
  • 1
merlin2011
  • 71,677
  • 44
  • 195
  • 329

1 Answers1

0

"android.intent.action.CREATE_SHORTCUT" is the official and the correct intent. You should be using it.

As for the S4, create shortcut could be bundled within the widgets category.

ozbek
  • 20,955
  • 5
  • 61
  • 84
  • Based on my testing, my app does not appear in the widgets category. However, it does appear when I use the command line to generate that Intent. – merlin2011 Feb 11 '15 at 05:16
  • Hmm.. probably, you could add a menu option to trigger that intent from your apps UI? Additionally, make the intent explicit to get rid of "Complete action with..." dialog. – ozbek Feb 11 '15 at 08:58
  • If I make the intent explicit, then it seems that returning the actual shortcut as an Intent will no longer work? Since CREAT_SHORTCUT is a special action that the system expects to return a shortcut. – merlin2011 Feb 11 '15 at 17:25
  • Right. Since you'd be the one installing the shortcut, you will have to add [`"com.android.launcher.permission.INSTALL_SHORTCUT"`](http://developer.android.com/reference/android/Manifest.permission.html#INSTALL_SHORTCUT) permission. – ozbek Feb 12 '15 at 06:03