Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does an image captured using camera intent gets rotated on some devices on Android?
    primarykey
    data
    text
    <p>I'm capturing an image and setting it to image view.</p> <pre><code>public void captureImage() { Intent intentCamera = new Intent("android.media.action.IMAGE_CAPTURE"); File filePhoto = new File(Environment.getExternalStorageDirectory(), "Pic.jpg"); imageUri = Uri.fromFile(filePhoto); MyApplicationGlobal.imageUri = imageUri.getPath(); intentCamera.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intentCamera, TAKE_PICTURE); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent intentFromCamera) { super.onActivityResult(requestCode, resultCode, intentFromCamera); if (resultCode == RESULT_OK &amp;&amp; requestCode == TAKE_PICTURE) { if (intentFromCamera != null) { Bundle extras = intentFromCamera.getExtras(); if (extras.containsKey("data")) { bitmap = (Bitmap) extras.get("data"); } else { bitmap = getBitmapFromUri(); } } else { bitmap = getBitmapFromUri(); } // imageView.setImageBitmap(bitmap); imageView.setImageURI(imageUri); } else { } } public Bitmap getBitmapFromUri() { getContentResolver().notifyChange(imageUri, null); ContentResolver cr = getContentResolver(); Bitmap bitmap; try { bitmap = android.provider.MediaStore.Images.Media.getBitmap(cr, imageUri); return bitmap; } catch (Exception e) { e.printStackTrace(); return null; } } </code></pre> <p>But the problem is, the image on some devices every time it gets rotated. For example, on a Samsung device it works good, but on a <a href="https://en.wikipedia.org/wiki/Sony_Xperia">Sony Xperia</a> the image gets rotated by 90 degrees and on <a href="https://en.wikipedia.org/wiki/Toshiba_Thrive">Toshiba Thrive</a> (tablet) by 180 degrees.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload