【发布时间】:2018-07-10 17:57:18
【问题描述】:
我必须实现一个允许用户拍照的功能,我需要强制屏幕方向为纵向。
更多的安卓设备,尤其是平板电脑,配备了安装在外壳顶部的后置摄像头(纵向模式),而其他设备则安装在平板电脑的侧面(横向模式)。
例如:
华为M2-A01L(侧面摄像头)
三星 Galaxy Tab A6(顶部有摄像头)
我需要人像模式下拍摄的所有照片,下面的代码是我实现但不起作用的代码。
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (cameraIntent.resolveActivity(getPackageManager()) != null) {
cameraIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
File storageDir = new File(Environment.getExternalStorageDirectory() + PDF_FOLDER_C);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
startActivityForResult(cameraIntent, idRow);
}
【问题讨论】: