JEFRI
JEFRI

Reputation: 21

Default Android 12 Camera with no access management of all file ResulltCode always 0

Default Android 12 Camera with no access management of all file ResulltCode always 0. But if using camera with Allow management of all files ResultCode 1. Anyway to fix this things? Thank You

PATH = "/storage/emulated/0/Android/media/bla/";

@OnClick(R.id.btn_photo_ktp) void btn_photo_ktp() {

File file = new File(Util.PATH_IMG, "img.img");
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
Uri outPutfileUri = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outPutfileUri);
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
startActivityForResult(intent, 1);

}

@Override public void onActivityResult(int requestCode, int resultCode, final Intent intent) {

super.onActivityResult(requestCode, resultCode, intent);
if (requestCode == 1) {
  if (resultCode == Activity.RESULT_OK) {
  }
}

}

Upvotes: 2

Views: 560

Answers (1)

blackapps
blackapps

Reputation: 9292

Uri.fromFile(file)

Do not use Uri.fromFile().

Use FileProvider to obtain a usable uri for the camera app.

Upvotes: 2

Related Questions