: public static void takePhoto(Fragment fragment, int token, Uri uri) {     Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);     intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION             | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);     if (uri != null) {         intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);         intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);     }     fragment.startActivityForResult(intent, token); }  