共享多个文件

//共享多个文件代码如下

ArrayList<Uri> uris = new ArrayList<Uri>();

for(int i = 0; i < size; i++){
        File file=(File)list.get(selectedItemIndexes[i]).get("file");
        mimeType = getMIMEType(file);
        Uri u = Uri.fromFile(file);
        uris.add(u);
      }
           boolean multiple = uris.size() > 1;
            Intent intent = new Intent(multiple ? android.content.Intent.ACTION_SEND_MULTIPLE
                    : android.content.Intent.ACTION_SEND);

            if (multiple) {
                intent.setType("*/*");
                intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
            } else {
                intent.setType(mimeType);
                intent.putExtra(Intent.EXTRA_STREAM, uris.get(0));
            }
            startActivity(Intent.createChooser(intent, "Share"));

 

posted @ 2013-01-10 10:25  枕头君  阅读(192)  评论(0编辑  收藏  举报