So I created camera app that works with camera intent, but for some reason on some phones it doesn't display pictures when they are captured. Later I found out that it mostly won't work with cameras higher then 8mpx. Here is my code that captures image:
Intent cameraIntent = newIntent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File output = new File(dir,"pic.png");
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(output));
path = output.getAbsolutePath();
startActivityForResult(cameraIntent, REQUEST_CODE_PHOTO);
And displaying them:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE_PHOTO) {
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
int targetW = width;
int targetH = height;
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, bmOptions);
int photoW = bmOptions.outWidth;
int photoH = bmOptions.outHeight;
int scaleFactor = Math.min(photoW/targetW, photoH/targetH);
bmOptions.inJustDecodeBounds = false;
bmOptions.inSampleSize = scaleFactor;
bmOptions.inPurgeable = true;
Bitmap bitmap = BitmapFactory.decodeFile(path, bmOptions);
iv.setImageBitmap(bitmap);
}
The problem is that it doesn't work with more than 8mpx camera phones like lg g2 and samsung note 3, but for some reason works on my zenfone 2 ze551ml. So I have no clue what can cause this issue maybe anyone have experience with this. Thanks in advance.