A continuación se muestra Mi código para crear un acceso directo a una aplicación seleccionada. Realmente no tengo ningún problema y la aplicación funciona bastante bien.Crear un acceso directo: ¿cómo puedo trabajar con un dibujable como icono?
El problema es que soy capaz de crear un acceso directo con un ressource de mi aplicación:
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.icon));
Pero realmente me gustaría con un dibujable personalizado. (Drawable myDrawable = .....)
¿Cómo puedo hacer?
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);
// Sets the custom shortcut's title
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, launchable.loadLabel(pm));
// Set the custom shortcut icon
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.icon));
// add the shortcut
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
sendBroadcast(intent);
finish();
Gracias mucho por cualquier pista
ShortcutIconResource.fromContext (pkgContext, IconId) haga el tric k! http://stackoverflow.com/questions/17339231/create-shortcut-for-thrid-party-app-is-that-possible/17561676#17561676 – thecr0w