我正试图通过意图将图像发送到其他应用程序...我正在从内部存储发送图像但我无法从我的SD卡分享...我如何从SD卡分享它。 ?
这是我的代码:
public void shareMultipleImages(View v) {
String imagePath1 = Environment.getExternalStorageDirectory()
+ "SD card/fb images/" + "gujju.jpg";
String imagePath2 = Environment.getExternalStorageDirectory()
+ "SD card/fb images/" + "zindgi.jpg";
// Multiple Images' file objects
File image1FileToShare = new File(imagePath1);
File image2FileToShare = new File(imagePath2);
// Get URI of Image's location
Uri image1URI = Uri.fromFile(image1FileToShare);
Uri image2URI = Uri.fromFile(image2FileToShare);
ArrayList<Uri> imageUris = new ArrayList<Uri>();
imageUris.add(image1URI); // Add your image URIs here
imageUris.add(image2URI); // Add your image URIs here
// Set the action to be performed i.e 'Send Multiple Data'
Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
// Add the URIs holding a stream of data
sendIntent.putExtra(Intent.EXTRA_STREAM, imageUris);
// Set the type of data i.e 'image/* which means image/png, image/jpg, image/jpeg etc.,'
sendIntent.setType("image/*");
// Launches the activity; Open 'Gallery' if you set it as default app to handle Image
startActivity(sendIntent);
}