Followed Android documentation to write code for launching native camera via intent:
http://developer.android.com/training/camera/photobasics.html
Problem: I am using Andorid Native Camera App for taking pictures from my app and launching via intent as mentioned in above link (MediaStore.ACTION_IMAGE_CAPTURE) and camera is launched successfully. When I click camera button of Native app to take pictures, image preview is mirrored while taking selfie (left image appears right) which selfie user would hate as image preview is not what he clicked.
Second - once image is clicked, it shows image preview and waits for user input for acceptance or rejection of picture.
Once image is accepted, OnStartActivityResult (as mentioned in above link) function receives the call and saves image to gallery. Strange thing here is that: Image gets inverted by 180 degree and then saved which is very weird behaviour.
Finally, two problems here: Image Preview Mirroing issue before user approves and while saving image invert issue (180 degree reverse).
Device: Samsung A6 Edge
Android: 5.1
Camera In Manifest File: Android.hardware.camera2 as Camera is deprecated
Please advise how can i fix above two issues.
Also- I have another doubt: Shall i use android native camera app or write the code using Camera Framework and launch custom camera? My requirement just to click pictures and show preview and save it with correct orientation. After searching a lot, I am doubtful - Can native camera app fix these issues? but your expert advise can help on this.
Any quick support and guidance on this is highly appreciated. Thanks in advance ! Here is the code:
public void triggerCamera() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File imagePath = AppPhotoHelper.getOutputMediaFile();
// Continue only if the File was successfully created
if (imagePath != null) {
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(imagePath));
takePictureIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
this.setImagePath(imagePath);
this.startActivityForResult(takePictureIntent, CAMERA_PIC_REQUEST);
}
}
onActivityResult function:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_PIC_REQUEST) {
if (resultCode == RESULT_OK ) {
//AppPhotoHelper is my class to show image in gallery
AppPhotoHelper.displayInGallery(this.getImagePath(), this);
//Image captured and stored in gallery ... camera invoked for next shot after doing some business processing
this.triggerCamera();
}
else if (resultCode == RESULT_CANCELED) {
return;
}
else {
return;
}
}
}