创建桌面图标
来源:互联网 发布:淘宝上如何买呼死你 编辑:程序博客网 时间:2024/04/30 04:42
- public class ShortcutUtil {
-
- public static void createShortCut(Activity act, int iconResId,
- int appnameResId) {
-
-
-
- Intent shortcutintent = new Intent(
- "com.android.launcher.action.INSTALL_SHORTCUT");
-
- shortcutintent.putExtra("duplicate", false);
-
- shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
- act.getString(appnameResId));
-
- Parcelable icon = Intent.ShortcutIconResource.fromContext(
- act.getApplicationContext(), iconResId);
- shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
-
- shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_INTENT,
- new Intent(act.getApplicationContext(), act.getClass()));
-
- act.sendBroadcast(shortcutintent);
- }
- }
- <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
-