创建桌面快捷方式
创建桌面快捷方式用到下面代码:
Intent shortcutIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.desktop));
配置文件加上:
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"></uses-permission>
Intent intent = new Intent();
intent.setComponent(new ComponentName(this.getPackageName(),".类名"));
增加启动参数:
Bundle bundle = new Bundle();
bundle.putInt("参数key", 参数值);
intent.putExtras(bundle);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
sendBroadcast(shortcutIntent);
浙公网安备 33010602011771号