Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Always open camera in landscape mode in Android

In my android app, after clicking on button I want camera to open in landscape mode. Even if I rotate my mobile into portrait mode, camera should always be in landscape mode or in portrait mode

like image 534
user1955234 Avatar asked Oct 19 '22 17:10

user1955234


1 Answers

Use This code for open camera in landscape mode

Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
File f = new File(Environment.getExternalStorageDirectory(), "temp.jpg");
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
startActivityForResult(cameraIntent, Utils.CAMERA__CROP_REQUEST);
like image 61
Milan Pansuriya Avatar answered Nov 15 '22 05:11

Milan Pansuriya