在Android中始终以横向模式打开相机 [英] Always open camera in landscape mode in Android

查看:99
本文介绍了在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);

这篇关于在Android中始终以横向模式打开相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆