Reputation: 4781
I am creating an application and part of it is where the user can change their profile picture either by taking a picture or using one from the native gallery.
So I'm using the native camera and I'm using the following lines of code to open the camera view
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image_saved_destination));
startActivityForResult(intent, CAMERA_REQUEST_CODE);
So with this it keeps overwriting the same file on the external storage.
This was working fine until I updated my os on one of my devices to lollipop. Now when I use the camera if I keep it in held in portrait and take the pic and save the orientation when it returns to my app flips from landscape to portrait. However, when the camera is open and if I hold the phone in landscape and take the pic and click save, it returns to the app with no orientation abnormalities.
Due to the orientation being changed and changed back I lose the state of the activity so my variables etc are lost, which are needed for processing the image data.
Has anyone encountered this?
Upvotes: 3
Views: 1260
Reputation: 18097
The ACTION_IMAGE_CAPTURE intent and the rotation between activity changes, are not related to the new Android camera2 API at all. This is just standard behavior of Android's intent system and switching between activities.
It sounds like the new OS comes with a new version of the native camera app, which has changed its behavior in terms of managing screen orientation. You should look into the standard approaches with managing orientation and other configuration changes: http://developer.android.com/guide/components/activities.html#ConfigurationChanges
Those will allow you to either handle the orientation change yourself instead of the OS restarting your activity, or allow you to stash your private data into a bundle that is given to you in onCreate.
Upvotes: 3
Reputation: 39
Better You create your own custom camera using camera API.If you encounter the same problem again then you can use setDisplayOrientation of camera preview.for more visit Android - Camera preview is sideways
Upvotes: -1