android之创建快捷方式
16lz
2021-12-04
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);}
为应用创建快捷方式,看如上代码
更多相关文章
- 动态创建ImageView视图
- Android(安卓)SQLiteOpenHelper的使用
- Android之快捷方式
- Android(安卓)封装http请求的工具类
- Android(安卓)删除SD卡文件和文件及创建文件夹和文件
- Android(安卓)SQLite使用
- Android(安卓)P Android.dp添加逻辑判断
- android工具详解
- Android(安卓)创建线程执行任务