Send multiple files using bluetooth in android programmatically

I am working on an Android application that will transfer multiple image files to another mobile device via a Bluetooth connection.

I used the following transfer method in android:

ArrayList<Uri> uris=new ArrayList<Uri>(); String multifile[]={"/sdcard/aaa.txt","/sdcard/bbb.txt","/sdcard/ccc.txt"}; int len=multifile.length; Intent Int=new Intent(); Int.setAction(android.content.Intent.ACTION_SEND_MULTIPLE); Int.setType("*/*"); for(int i=0;i<len;i++) { File file=new File(multifile[i]); uris.add(Uri.fromFile(file)); } Int.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); startActivity(Int); 

This method has successfully transferred files. But I only have nine images on an Android phone, and then my application will go to another set of 9 images that need to be transferred, because I have to call the above selection wizard to send files. But I do not want the user to select an option from chooser again again.

Is there a way to send files through this option (bluetooth from wizard) silently (without user intervention)?

+4
source share
2 answers

This worked for me:

Instead of putParcelableArrayListExtra use putExtra(Intent.EXTRA_STREAM, uris)

It was asked a month ago, so I don’t know how important this is for you, but maybe it helps someone else. :)

+1
source
 ArrayList<Uri> uris = new ArrayList<Uri>(); mul = fileSelectorList; Log.d("final",""+mul); int length = mul.size(); //Toast.makeText(ImageActivity.this, "Send", Toast.LENGTH_LONG).show(); //mail_int.setAction(android.content.Intent.ACTION_VIEW); mail_int.setAction(android.content.Intent.ACTION_SEND_MULTIPLE); //mail_int.setAction(android.content.Intent.ACTION_TIME_CHANGED); mail_int.setType("image/*"); for(int i = 0; i < length; i++) { File file = new File(mul.get(i)); uris.add(Uri.fromFile(file)); } mail_int.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); startActivity(mail_int); 
+1
source

Source: https://habr.com/ru/post/1432867/


All Articles