简体   繁体   中英

Sending multiple files via bluetooth

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);


    }

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. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM