Back to project page Alfred4Android.
The source code is released under:
Apache License
If you think the Android project Alfred4Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.toraleap.collimator.util; //from www. ja v a2 s.c om import android.content.Context; import android.content.Intent; import android.content.Intent.ShortcutIconResource; /** * ???????????????????????? * @author uestc.Mobius <mobius@toraleap.com> * @version 2010.1104 */ public final class ShortcutHelper { private static final String ACTION_INSTALL_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT"; private static final String EXTRA_SHORTCUT_DUPLICATE = "duplicate"; private Context mContext; private String mName; private Intent mIntent; private ShortcutIconResource mIconResource; /** * ???????? Intent ?????????????????? * @param context ????????? * @param intent ??????? Intent ???? */ public ShortcutHelper(Context context, Intent intent) { mContext = context; mIntent = intent; } /** * ????????????????? * @param name ???????????? * @return ?????????? */ public ShortcutHelper setName(String name) { mName = name; return this; } /** * ???????????????????? * @param iconResource ????????? * @return ?????????? */ public ShortcutHelper setIconResource(ShortcutIconResource iconResource) { mIconResource = iconResource; return this; } /** * ????????????????? * @param duplicate ???????????????????? */ public void install(boolean duplicate) { Intent installIntent = new Intent(ACTION_INSTALL_SHORTCUT); installIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, mName); installIntent.putExtra(EXTRA_SHORTCUT_DUPLICATE, duplicate); installIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, mIntent); installIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, mIconResource); mContext.sendBroadcast(installIntent); } }