【问题标题】:Using Intent.ACTION_SEND_MULTIPLE send multiple files through Bluetooth使用 Intent.ACTION_SEND_MULTIPLE 通过蓝牙发送多个文件
【发布时间】:2013-09-27 15:07:40
【问题描述】:

我已经看到了一些使用 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"));
    }

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

【问题讨论】:

    标签: android android-intent bluetooth file-transfer


    【解决方案1】:

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

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

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

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

    不必要的意图选择器!

    【讨论】:

      猜你喜欢
      • 2012-02-14
      • 1970-01-01
      • 2011-09-01
      • 1970-01-01
      • 2018-06-30
      • 2019-07-26
      • 2012-01-01
      相关资源
      最近更新 更多