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);}

为应用创建快捷方式,看如上代码

更多相关文章

  1. 动态创建ImageView视图
  2. Android(安卓)SQLiteOpenHelper的使用
  3. Android之快捷方式
  4. Android(安卓)封装http请求的工具类
  5. Android(安卓)删除SD卡文件和文件及创建文件夹和文件
  6. Android(安卓)SQLite使用
  7. Android(安卓)P Android.dp添加逻辑判断
  8. android工具详解
  9. Android(安卓)创建线程执行任务

随机推荐

  1. Android(安卓)Studio NDK开发入门
  2. Android(安卓)TabHost(简易用法)
  3. Android(安卓)面试
  4. android iphone手机分辨率尺寸比例整理
  5. Android(安卓)Market on Emulator
  6. Android编译系统 - pathmap.mk(宏)
  7. Android(安卓)TextView 竖线
  8. Android(安卓)android-common 常用功能和
  9. Android(安卓)8.0 添加HIDL
  10. [转]Setting up a Device for Developmen