Android创建快捷方式(shortcut)
文章分类:移动开发
创建应用程序的快捷方式如下:
Action
Java代码
private static final String ACTION_INSTALL_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT";
Java代码
Intent shortcutIntent = new Intent(ACTION_INSTALL_SHORTCUT);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
getString(R.string.app_name));
shortcutIntent.putExtra(EXTRA_SHORTCUT_DUPLICATE, false);
Intent intent = new Intent();
intent.setComponent(new ComponentName(this.getPackageName(),
".Splash"));
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(this,
R.drawable.icon));
sendBroadcast(shortcutIntent);
Uses permission
Xml代码
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
更多相关文章
- Android(安卓)利用TransitionDrawable 实现两张图片渐变切换
- android 中调用系统的发短信功能
- android 代码中设置字体大小
- 关于Android(安卓)Studio3.0使用过程的一些报错
- [置顶] Android常用功能代码
- android 如何判断程序是否在前台运行
- Android(安卓)屏幕截图 代码
- Android(安卓)关于wifi管理的代码
- Android用代码安装APK,不用选择“打包安装程序”