在Android中始终以横向模式打开相机

问题描述:

在我的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

使用此代码在横向模式下打开相机

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);