I am trying to use Intent for sharing.It works well with single image or when I use Intent.ACTION_SEND.
But when i use Intent.ACTION_SEND_MULTIPLE It does not seems
Further to the accepted answer (which I have upvoted) here is another method, which also closes the cursor:
private Uri getContentUri(Context context, String contentPath) {
Cursor c = context.getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[]{MediaStore.Images.ImageColumns._ID, MediaStore.Images.ImageColumns.DATA},
MediaStore.Images.ImageColumns.DATA + "=?",
new String[]{contentPath},
null
);
Uri contentUri = null;
try {
if (c != null && c.getCount() > 0 && c.moveToFirst()) {
int colId = c.getColumnIndex(MediaStore.Images.ImageColumns._ID);
if (colId > -1) {
int id = c.getInt(colId);
contentUri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, Integer.toString(id));
}
}
} catch (Exception e) {
} finally {
try {
if (c != null) {
c.close();
}
} catch (Exception e) {}
}
return contentUri;
}