通过蓝牙发送多个文件 [英] Sending multiple files via bluetooth

查看:86
本文介绍了通过蓝牙发送多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码通过蓝牙将文件从一台设备发送到另一台设备.我想同时发送多个文件,谁能指导我如何解析多个URI到文件.我尝试使用字符串标记器和while循环来完成此操作,但在这种情况下,默认情况下蓝牙请求会出现两次.如果有两个文件解析).

I am using below code to send a file via blue-tooth from one device to another. I want to send multiple file at the same time.Can anyone guide me how to parse multiple URI to file.I tried doing it with string tokenizer and while loop but in that case, by-default blue-tooth request is coming twice.(if there are two files parsing).

StringTokenizer tokens = new StringTokenizer(music, ",");

    String stored = "";
    while (tokens.hasMoreTokens()) {

        stored = tokens.nextToken();


        File file = new File(stored);
        Log.d("file===", stored);

        intentfile = new Intent();
        intentfile.setAction(android.content.Intent.ACTION_SEND);

        intentfile.setType("video/*");

        intentfile.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
        startActivityForResult(intentfile, SEND_REQUEST);


    }

推荐答案

我使用setAction(Intent.ACTION_SEND_MULTIPLE)而不是setAction(Intent.ACTION_SEND)来发送(或共享)多个文件.

I use setAction(Intent.ACTION_SEND_MULTIPLE) instead of setAction(Intent.ACTION_SEND) to send (or share) multiple files.

六个月前有人问过这个问题,所以现在不知道它与您有多相关.但这也许可以帮助其他人. :)

It was asked 6 months ago, so don't know how relevant it is to you now. But may be it can help someone else. :)

这篇关于通过蓝牙发送多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆