Je pense avoir essayé toutes les solutions que j'ai trouvées sur Internet, mais personne n'a travaillé - pas de force, mais rien n'apparaît sur le bureau. Maintenant, j'ai ceci:Créer un raccourci pour n'importe quelle application sur le bureau
private void createShortcutOnDesktop(Application app) {
Intent shortcutIntent = new Intent();
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, app.getIntentShortcut());
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, app.getName());
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.home_button));
shortcutIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
this.sendBroadcast(shortcutIntent);
finish();
}
Le app.getIntentShortcut() est la suivante:
public Intent getIntentShortcut()
{
Intent i = new Intent();
i.setClassName(packageName, name);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
return i;
}
Et dans le manifeste:
<permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
Qu'est-ce que je manque? Merci.
Pour référence, l'édition de votre question suffit à augmenter jusqu'à à la première page à nouveau. –
pouvez-vous s'il vous plaît, fournir le code source complet. – Nirav