android之创建快捷方式
16lz
2021-01-23
private void addShortcut() {Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));shortcut.putExtra("duplicate", false); // 不允许重复创建ComponentName comp = new ComponentName(this.getPackageName(), "." + Contants.MAIN_ACTION);shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(Intent.ACTION_MAIN).setComponent(comp));ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon);shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);sendBroadcast(shortcut);}
为应用创建快捷方式,看如上代码
更多相关文章
- Android 6.0 源代码编译实践
- Android之常用功能代码
- android客户端加密代码
- Android如何通过代码将res里的图片转换成drawable.
- Android引入外部字体源代码
- Android APP 版本更新通知代码
- Android图片放大修改代码
- Android获取基站坐标代码
- Android——实现在纯Java代码里写布局
随机推荐
- Android:什么情况?
- Android深入理解android:layout_gravity
- android布局文件中各属性所代表的意义
- Android(安卓)WebView与 JS 的交互方式
- android:layout_gravity和android:gravit
- android:layout_gravity和android:gravit
- android:layout_gravity和android:gravit
- android中线程进程模型
- android:layout_gravity和android:gravit
- android:layout_gravity和android:gravit