标签:
/** * Activity Action: Creates a shortcut. * <p>Input: Nothing.</p> * <p>Output: An Intent representing the shortcut. The intent must contain three * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String), * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE * (value: ShortcutIconResource).</p> * * @see #EXTRA_SHORTCUT_INTENT * @see #EXTRA_SHORTCUT_NAME * @see #EXTRA_SHORTCUT_ICON * @see #EXTRA_SHORTCUT_ICON_RESOURCE * @see android.content.Intent.ShortcutIconResource */
public void CreateShotCast(Context context, Class<?> clazz) { Intent shortcut = new Intent(Intent.ACTION_CREATE_SHORTCUT); Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); shortcutIntent.setClass(context, clazz); shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "测试"); // Intent.EXTRA_SHORTCUT_ICON 是bitmap对象 shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeFile("路径")); context.sendBroadcast(shortcut); }
标签:
原文地址:http://blog.csdn.net/windowsxp2014/article/details/45822757