On any version before android lollipop, the below code works fine. For some reason, from a certain version of android (around 5.0), whenever an image is captured from camera, the screen rotates 90 degrees to the right and back (Not only auto-rotate on my device is off, my activity is defined as portrait, it's not supposed to be rotating at all!). Once the screen rotates back, the ImageView presents the previous (original) image. Any suggestions?
The camera intent:
if (result.equals("CAMERA"))
{
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, RESULT_IMAGE_CAPTURE);
}
The actual action:
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
Bitmap bmp = null;
if (requestCode == RESULT_IMAGE_CAPTURE && resultCode == RESULT_OK && data != null)
Bitmap bmp = (Bitmap) data.getExtras().get("data");
if (bmp != null)
{
mProfilePicPath = ImageHandler.saveBitmap(bmp , "", "image_name");
mProfilePic.setImageBitmap(bmp);
}
}
EDIT: Apparently when going back to my activity from the camera intent, rather than just the onResume() method to be called, the onCreate() method is called, and not just once, but twice! The first time is not a problem, since the onActivityResult method called after it. The second time, though, re-initiates both mProfilePic (my ImageView) and mProfilePicPath, which I want to use later. Any ideas?