1

I am attempting to take a captured image and display to the Activity. When the image is set, it gets rotated to the right 90 degrees. I'm not sure what I am doing wrong. I capture the image by using MediaStore.ACTION_IMAGE_CAPTURE and saved it and set it with a URI. Here's the code:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_selectusername);

    confirm = (Button) findViewById(R.id.confirm_select);
    confirm.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            takePhoto();

        }
    });

}

private void takePhoto() {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    File photo = new File(Environment.getExternalStorageDirectory(), "temp.jpg");
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));

    //This is for photo editing purposes
    inputURI = Uri.fromFile(photo);
    outputURI = Uri.fromFile(new File(getCacheDir(), photoname));

    //Cropping, Resizing, etc. takes place

    startActivityForResult(intent, TAKE_PICTURE);


}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent result) {
    super.onActivityResult(requestCode, resultCode, result);
    if(requestCode == TAKE_PICTURE && resultCode == RESULT_OK){
        ImageView imageView = (ImageView) findViewById(R.id.profilepicture_select);

        imageView.setImageURI(outputURI);

    }else{
        Log.d("TEST", "Something went wrong!");
    }
}

I can show more code and clarify if necessary. All Help is appreciated!

HTG
  • 584
  • 1
  • 8
  • 28
  • http://stackoverflow.com/questions/14066038/why-image-captured-using-camera-intent-gets-rotated-on-some-devices-in-android, try this link as it is issue with some android devices – Reprator Jul 30 '15 at 03:10

1 Answers1

0

Your code looks fine. It's likely a problem with the device's camera. This is a known issue for the Galaxy S4. Some devices output strange exif data which results in the image being off when you display it. How do you fix it?

Here's a lead for you: Android camera/picture orientation issues with Samsung Galaxy S3, S4, S5

Community
  • 1
  • 1
a person
  • 986
  • 6
  • 13