so i have created 2 different app lists one which stores the app drawer and this one works fine i can displa y apps and launch them. Im using the same process to create a app list for shortcuts but instead of a gridview im using a listview in a popup .. This all works fine displays the list fine. when i click on it the onclicklistener works as well. now my problem is adding the shortcuts to my home screen inside my launcher not the android launcher but my own custom launcher. which is all part of the same project.
the code below has been changed multiple times and now im just trying to get it where it creates a shortcut for my app which this is not working either
the astro_label,icon,name are the ones i want to use to grab the information from the item clicked those return values just fine.
btw mContext is Context mContext;
any help would be grant thank you
the code below has been changed multiple times and now im just trying to get it where it creates a shortcut for my app which this is not working either
the astro_label,icon,name are the ones i want to use to grab the information from the item clicked those return values just fine.
btw mContext is Context mContext;
any help would be grant thank you
PHP Code:
//Code for creating Shortcut to home screen
/* string astro_label = pacsForAdapter[pos].label;
string astro_icon = pacsForAdapter[pos].icon;
string astro_name = pacsForAdapter[pos].name;
*/
// a Intent to create a shortCut
Intent shortcutintent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
//repeat to create is forbidden
shortcutintent.putExtra("duplicate", false);
//set the name of shortCut
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "MY APP");
//set icon
Parcelable icon = Intent.ShortcutIconResource.fromContext(mContext.getApplicationContext(), R.drawable.ic_launcher);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
//set the application to launch when you click the icon
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(mContext.getApplicationContext() , HomeActivity.class));
//sendBroadcast,done
mContext.sendBroadcast(shortcutintent);
0 commentaires:
Enregistrer un commentaire