Java tutorial
//package com.java2s; import android.content.ClipData; import android.content.Intent; import android.net.Uri; import android.provider.MediaStore; public class Main { private static void addPhotoPickerExtras(Intent intent, Uri photoUri) { intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setClipData(ClipData.newRawUri(MediaStore.EXTRA_OUTPUT, photoUri)); } }