List of usage examples for android.content Intent EXTRA_SHORTCUT_INTENT
String EXTRA_SHORTCUT_INTENT
To view the source code for android.content Intent EXTRA_SHORTCUT_INTENT.
Click Source Link
From source file:com.amaze.carbonfilemanager.fragments.MainFragment.java
private void addShortcut(LayoutElement path) { //Adding shortcut for MainActivity //on Home screen Intent shortcutIntent = new Intent(getActivity().getApplicationContext(), MainActivity.class); shortcutIntent.putExtra("path", path.getDesc()); shortcutIntent.setAction(Intent.ACTION_MAIN); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, new File(path.getDesc()).getName()); addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getActivity(), R.mipmap.ic_launcher)); addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); getActivity().sendBroadcast(addIntent); }
From source file:com.android.leanlauncher.LauncherModel.java
ShortcutInfo infoFromShortcutIntent(Context context, Intent data) { Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); if (intent == null) { // If the intent is null, we can't construct a valid ShortcutInfo, so we return null Log.e(TAG, "Can't construct ShorcutInfo with null intent"); return null; }//from ww w. ja v a 2 s . com final ShortcutInfo info = new ShortcutInfo(); // Only support intents for current user for now. Intents sent from other // users wouldn't get here without intent forwarding anyway. info.user = UserHandleCompat.myUserHandle(); info.title = name; info.contentDescription = mUserManager.getBadgedLabelForUser(info.title.toString(), info.user); info.intent = intent; // cache the icon for shortcut mIconCache.getAppIcon(info); return info; }
From source file:com.cognizant.trumobi.PersonaLauncher.java
private void completeEditShirtcut(Intent data) { if (!data.hasExtra(PersonaCustomShirtcutActivity.EXTRA_APPLICATIONINFO)) return;/*from w w w .java2 s .co m*/ long appInfoId = data.getLongExtra(PersonaCustomShirtcutActivity.EXTRA_APPLICATIONINFO, 0); PersonaApplicationInfo info = PersonaLauncherModel.loadApplicationInfoById(this, appInfoId); if (info != null) { Bitmap bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON); Drawable icon = null; boolean customIcon = false; ShortcutIconResource iconResource = null; if (bitmap != null) { icon = new PersonaFastBitmapDrawable(PersonaUtilities.createBitmapThumbnail(bitmap, this)); customIcon = true; } else { Parcelable extra = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE); if (extra != null && extra instanceof ShortcutIconResource) { try { iconResource = (ShortcutIconResource) extra; final PackageManager packageManager = getPackageManager(); Resources resources = packageManager.getResourcesForApplication(iconResource.packageName); final int id = resources.getIdentifier(iconResource.resourceName, null, null); icon = resources.getDrawable(id); } catch (Exception e) { PersonaLog.w(LOG_TAG, "Could not load shortcut icon: " + extra); } } } if (icon != null) { info.icon = icon; info.customIcon = customIcon; info.iconResource = iconResource; } info.itemType = PersonaLauncherSettings.Favorites.ITEM_TYPE_SHORTCUT; info.title = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); info.intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); PersonaLauncherModel.updateItemInDatabase(this, info); if (info.container == PersonaLauncherSettings.Favorites.CONTAINER_MAB) mHandleView.UpdateLaunchInfo(info); else if (info.container == PersonaLauncherSettings.Favorites.CONTAINER_LAB) mLAB.UpdateLaunchInfo(info); else if (info.container == PersonaLauncherSettings.Favorites.CONTAINER_LAB2) mLAB2.UpdateLaunchInfo(info); else if (info.container == PersonaLauncherSettings.Favorites.CONTAINER_RAB) mRAB.UpdateLaunchInfo(info); else if (info.container == PersonaLauncherSettings.Favorites.CONTAINER_RAB2) mRAB2.UpdateLaunchInfo(info); mWorkspace.updateShortcutFromApplicationInfo(info); } }