使用Intent.ACTION_SEND_MULTIPLE通过蓝牙发送多个文件

时间:2013-09-22 18:03:18

标签: android android-intent bluetooth file-transfer

我已经看到了使用intent.ACTION_SEND_MULTIPLE的其他一些示例。但他们就是榜样

全部写电子邮件。我的问题是我要发送大约十个文件,而且我使用了意图

通过蓝牙发送,我可以成功将这些文件发送到其他设备,但它将

出现意图选择器十次,我只想让它出现一次或我可以分配

意图使用蓝牙提前发送文件,而不是弹出任何选择器。任何人都可以

给我一​​些建议?

以下是我的代码:

ArrayList<File> fileList = new ArrayList<File>();
    ArrayList<Uri> files = new ArrayList<Uri>(); 

    StringTokenizer tokens = new StringTokenizer(options, ","); 
     String stored = "";
        while (tokens.hasMoreTokens()) {
            stored = tokens.nextToken();
            File file = new File(stored);
            fileList.add(file);
        }

        for(File file : fileList ) {
            Uri uri = Uri.fromFile(file);
            files.add(uri);
        }
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_SEND_MULTIPLE);
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
        intent.setType("image/*");
        startActivity(Intent.createChooser(intent, "select some pic"));
    }

提前感谢您查看我的问题!

1 个答案:

答案 0 :(得分:1)

我终于找到了答案,我添加了以下代码,它完美无缺

如果有人遇到问题,也许你可以尝试一下!

intent.setPackage("com.android.bluetooth"); 

它会选择蓝牙仅共享文件,不会出现任何

不必要的意图选择者!

相关问题