4

Here i am sharing images from my app to whatsapp.but this code is working here only for mylist1[i] and not for mylist2[i] and mylist3[i]. As in my activity file there are 15 images in every list. what to do?

Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/*");
Uri uri = Uri.parse("android.resource://com.example.drawcelebrities/"+mylist1[i]+mylist2[i]+mylist3[i]);
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "Share via"));
AndyN
  • 1,742
  • 1
  • 15
  • 30
user3432085
  • 87
  • 1
  • 9
  • Refer this link: http://stackoverflow.com/questions/15577438/how-can-i-share-multiple-files-via-an-intent – Lokesh Mar 24 '14 at 07:11

3 Answers3

2

Take image array in mylist[] and use below code, then share image via whatsapp.

Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+mylist[i]);

Intent shareIntent = new Intent();
             shareIntent.setAction(Intent.ACTION_SEND);
             shareIntent.setType("image/*");
             shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
             startActivity(Intent.createChooser(shareIntent, "Share via"));
abhi
  • 154
  • 16
0

If I'm not wrong then for that you should use android.content.Intent.ACTION_SEND_MULTIPLE..Refer this link it will help you..

Community
  • 1
  • 1
Akshay
  • 6,029
  • 7
  • 40
  • 59
-1
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND_MULTIPLE);
intent.putExtra(Intent.EXTRA_SUBJECT, "Here are some files.");
intent.setType("image/jpeg");
ArrayList<Uri> files = new ArrayList<Uri>();
for(String path : filesToSend /* List of the files you want to send */) {
File file = new File(path);
 Uri uri = Uri.fromFile(file);
files.add(uri);
}
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
startActivity(intent);
Nathan Tuggy
  • 2,237
  • 27
  • 30
  • 38
Bilal Mustafa
  • 750
  • 7
  • 16