Android 如何将我的应用程序中的图像共享到whatsapp?

Android 如何将我的应用程序中的图像共享到whatsapp?,android,share,Android,Share,在这里,我正在将我的应用程序中的图像共享到whatsapp。但此代码仅适用于mylist1[i],而不适用于mylist2[i]和mylist3[i]。在我的活动文件中,每个列表中有15个图像。怎么办 Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("image/*"); Uri uri = Uri.parse("android.resource://com.example.dr

在这里,我正在将我的应用程序中的图像共享到whatsapp。但此代码仅适用于mylist1[i],而不适用于mylist2[i]和mylist3[i]。在我的活动文件中,每个列表中有15个图像。怎么办

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

如果我没有错的话,那么你应该使用android.content.Intent.ACTION\u SEND\u MULTIPLE。参考这一点,它将帮助你..

在mylist[]中拍摄图像数组并使用下面的代码,然后通过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"));
Intent Intent=新Intent();
intent.setAction(intent.ACTION\u SEND\u MULTIPLE);
intent.putExtra(intent.EXTRA_主题,“这里有一些文件”);
intent.setType(“图像/jpeg”);
ArrayList files=新的ArrayList();
for(字符串路径:filesToSend/*要发送的文件列表*/){
文件=新文件(路径);
Uri=Uri.fromFile(文件);
添加(uri);
}
intent.putParcelableArrayListExtra(intent.EXTRA\u流,文件);
星触觉(意向);
请参阅此链接:
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);