【问题标题】:How to lock the orientation to Portrait when using intent ACTION_IMAGE_CAPTURE?使用意图 ACTION_IMAGE_CAPTURE 时如何将方向锁定为纵向?
【发布时间】:2015-09-06 19:46:03
【问题描述】:

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

这是一个示例代码:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
startActivityForResult(intent, TAKE_PICTURE);

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

任何帮助将不胜感激。

编辑:发现关于该主题的另一个尚未回答的问题: How to lock the camera app orientation called through intent in android?

【问题讨论】:

  • 你试过setDisplayOrientation方法吗????
  • @KeyurLakhani 我不确定是否可以将它与MediaStore.ACTION_IMAGE_CAPTURE 方法一起使用。
  • 尝试使用intent i.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  • @KeyurLakhani 谢谢,我试过了,但没有任何效果。作为记录,设备上的屏幕方向也锁定为纵向,但相机应用仍然可以横向拍照。
  • 对不起!!运气不好,但最后这可能有用stackoverflow.com/questions/6813166/…

标签: android android-camera-intent


【解决方案1】:

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

所以我决定按照 cmets 中的建议,通过 setDisplayOrientation 方法在代码中实现自定义相机并设置方向。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-07
    相关资源
    最近更新 更多