Android创建快捷方式(shortcut)
16lz
2022-06-16
创建应用程序的快捷方式如下:
Action
private static final String ACTION_INSTALL_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT";
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
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
删除快捷方式试了很久没测试成功过,不知那位同学贡献一下代码?
更多相关文章
- android调用js
- Android(安卓)webview监听网页对话框点击事件
- Android中ExpandableListView控件基本使用
- Android(安卓)将自己的应用程序改成系统的应用程序
- Android(安卓)学习笔记
- 安装和卸载Android应用程序(apk包)
- Android高手进阶教程(五)之----Android(安卓)中LayoutInflater的
- android 自定义 permission 权限
- 在Android上本机运行的服务器