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. Android 6.0 源代码编译实践
  2. Android之常用功能代码
  3. android客户端加密代码
  4. Android如何通过代码将res里的图片转换成drawable.
  5. Android引入外部字体源代码
  6. Android APP 版本更新通知代码
  7. Android图片放大修改代码
  8. Android获取基站坐标代码
  9. Android——实现在纯Java代码里写布局

随机推荐

  1. Android:什么情况?
  2. Android深入理解android:layout_gravity
  3. android布局文件中各属性所代表的意义
  4. Android(安卓)WebView与 JS 的交互方式
  5. android:layout_gravity和android:gravit
  6. android:layout_gravity和android:gravit
  7. android:layout_gravity和android:gravit
  8. android中线程进程模型
  9. android:layout_gravity和android:gravit
  10. android:layout_gravity和android:gravit