/**
* 为程序创建桌面快捷方式
*/
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); //不允许重复创建
//指定当前的Activity为快捷方式启动的对象: 如
//com.everest.video.VideoPlayer
//注意: ComponentName的第二个参数必须加上点号(.),否则快捷方式无法启动相应程序
ComponentName comp = new ComponentName(this.getPackageName(), “.”+this.getLocalClassName());
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中创建文件以及文件夹
  2. Android(安卓)创建单独的服务运行在后台(无界面)
  3. Android(安卓)创建菜单
  4. android 将bitmap缓存到本地
  5. Android获取apk的版本及包名等信息
  6. android创建自定义对话框
  7. Android(安卓)封装http请求的工具类
  8. Android(安卓)room操作数据库
  9. Android创建和删除桌面快捷方式

随机推荐

  1. Android(安卓)EventBus 封装(支持多个粘性
  2. Android应用程序绑定服务(bindService)的过
  3. android外存储的状态
  4. Android(安卓)地址转换为经纬度
  5. Android(安卓)View 相关源码分析之三 Vie
  6. Android直播开源项目
  7. Android(安卓)HAL的被调用流程
  8. Android属性动画上手实现各种动画效果,自
  9. 2013年01月06日
  10. android Activity类的使用