yanivtwin
yanivtwin

Reputation: 625

ACTION_IMAGE_CAPTURE on samsung device blurred

I'm using this code to open camera intent :

Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
takePicture.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
startActivityForResult(takePicture, 0);

And it works fine but only on Samsung devices (8\9) with android 8 after I take a picture the preview is all blurry , anyone got that weird behavior ?

( I also tried without the putExtra line )

Here are the screenshots :

before

after[![][1]]3

Upvotes: 1

Views: 648

Answers (1)

rya
rya

Reputation: 1506

you have to give a photo path Uri as an extra in the camera intent as:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory(), mUserID + ".jpg");
Uri photoPath = getUriForFile(mContext, BuildConfig.APPLICATION_ID, file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoPath);   //--> here 
startActivityForResult(Intent.createChooser(intent, "Complete action using"), REQUEST_CODE_CAMERA);

then, you can get the captured image in that Uri itself in onActivityResult

Upvotes: 3

Related Questions