Below my code creates a shortcut for the selected application. I really have no problem and the application works quite well.
The problem is that I can create a shortcut with ressource from my application:
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.icon));
But I really would like with the help of a user feature. (Drawable myDrawable = .....)
How can i do this?
ResolveInfo launchable=adapter.getItem(position); final Intent shortcutIntent = new Intent(); ActivityInfo activity=launchable.activityInfo; ComponentName name=new ComponentName(activity.applicationInfo.packageName,activity.name); shortcutIntent.setComponent(name); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); final Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
Thanks so much for any clue
android android-intent drawable icons shortcut
Waza_be
source share