O
O
oe24y2014-04-24 09:51:41
Android
oe24y, 2014-04-24 09:51:41

How to display app shortcut on desktop after installing it [android]?

I mean in the code, and not in the Google Play settings, for example.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2014-04-24
@oe24y

There's no way to test it right now, but check out this solution (from stackoverflow):

public void createShortCut(){
    Intent shortcutintent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
    shortcutintent.putExtra("duplicate", false);
    shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.shortcutname));
    Parcelable icon = Intent.ShortcutIconResource.fromContext(getApplicationContext, R.drawable.icon);
    shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
    shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(getApplicationContext, EnterActivity.class));
    sendBroadcast(shortcutintent);
}

I re-read the rules of the Toaster, it seems there are no prohibitions on posting links to other resources, here is the solution: stackoverflow.com/questions/18327173/how-can-i-add... here is another similar one: stackoverflow.com/questions/4854197/how- can i poster...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question