使用意图 ACTION_IMAGE_CAPTURE 时如何将方向锁定为纵向?

Apo*_*fix 5 android android-camera-intent

我知道我可以在清单中设置活动的方向,但是当此活动调用MediaStore.ACTION_IMAGE_CAPTURE打开相机并拍照时,用户仍然可以以横向模式拍照。我可以将相机应用程序本身的方向锁定为纵向吗?

这是示例代码:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
startActivityForResult(intent, TAKE_PICTURE);
Run Code Online (Sandbox Code Playgroud)

我想阻止用户拍摄任何风景照片。

任何帮助将不胜感激。

编辑:发现该主题的另一个问题尚未得到解答: How to lock the Camera app Direction Called through Intent in android?

Apo*_*fix 3

经过一段时间的使用后,在使用 时,似乎无法将方向锁定为纵向Intent MediaStore.ACTION_IMAGE_CAPTURE

因此,我决定实现一个自定义相机,并通过方法在代码中设置方向setDisplayOrientation,如评论中所建议的。

基本上,这不是问题的解决方案,而只是“解决”问题的另一种方法,但是它适合我的情况,因为我还能够处理用户界面并对默认界面进行一些更改。