ES文件浏览器有个功能可以把单个文件或者目录在桌面上建立快捷方式,不知道是怎么做的.
网上搜索了一下,全都是安装包建立快捷方式,没有目录或者单个文件的,请问这个应该怎么实现?谢谢!

解决方案 »

  1.   

    网上的例子修改下
    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); //不允许重复创建

    //假设是图片类型
    File file=new File("/sdcard/IMG/1.jpg");     
    Uri mUri = Uri.parse("file://"+file.getPath());
    Intent it = new Intent(Intent.ACTION_VIEW);
    it.setDataAndType(mUri, "image/*");//自己可以设置类型
    shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, it);

    //快捷方式的图标
    ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(MainActivity.this, R.drawable.icon);
    shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);

    sendBroadcast(shortcut);
      

  2.   

    用你的方法做swf的快捷方式可以吗