MediaStore.ACTION_VIDEO_CAPTURE崩溃相机应用,如果设备是纵向 [英] MediaStore.ACTION_VIDEO_CAPTURE crashes camera app if device is portrait

查看:707
本文介绍了MediaStore.ACTION_VIDEO_CAPTURE崩溃相机应用,如果设备是纵向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是标准的 MediaStore.ACTION_VIDEO_CAPTURE 意图调用(如一个在开发者网站或地段计算器线程)来记录一​​些视频。我在测试它(真)的Nexus 7(API 21),并能正常工作...的只要设备的显示是在景观方向时(本地)的Andr​​oid相机应用启动的。如果是纵向,反纵向或反向景观,相机应用完成初始化(不幸的是,相机已停止),并控制返回到我的应用程序停止一部分的方式。相机应用乐意重新调整为纵向,一旦它在景观已初始化,但是。如果我用 MediaStore.ACTION_IM​​AGE_CAPTURE ,它会开始在纵向或横向。

我知道我可以解决我的应用程序为横向的方向,我知道我可以要求相机的风景记录下来,但如果用户恰好反正持股待人像设备,屏幕在旋转到垂直转型,因为我的应用程序版本控制的相机应用。相机应用程序,然后获得控制,而方向是纵向,它不喜欢它,并停止。问题是的的因的变更的方向 - 哪怕我把一切都贯穿锁定人像,相机应用通过其初始化程序取消部分路

有没有办法来避免这种情况的发生(同时仍通过意向使用摄像机)?

(PS我从这里,关于定制的摄像头程序通知: ?注:相机preVIEW并不一定要在横向模式下......,并接着解释如何做到这一点这是否意味着意图实现不执行)


解决方案

  

有没有办法来避免这种情况的发生(同时仍通过意向使用摄像机)?


没有。

更具体地说,有成千上万的摄像头可能的应用程序 - preloaded或用户安装 - 这可能声称支持 ACTION_VIDEO_CAPTURE ,和任何人都可以有错误,因为这人做。没有 EXTRA_PLEASE_AVOID_BUGS ,你可以通过对意图更改(尽管这会是的真的的凉...)。

I'm using a standard MediaStore.ACTION_VIDEO_CAPTURE Intent call (e.g. the one on the Developer site or lots of StackOverflow threads) to record some video. I'm testing it on a (real) Nexus 7 (API 21) and it works fine...so long as the device's display is in a landscape orientation when the (native) Android camera app starts up. If it is portrait, reverse-portrait or reverse-landscape, the camera app stops part way through its initialization ("Unfortunately, Camera has stopped") and control returns to my app. The camera app is happy to reorient to portrait once it has initialized in landscape, however. And if I use MediaStore.ACTION_IMAGE_CAPTURE, it'll start in portrait or landscape.

I know that I can fix the orientation of my app to landscape and I know that I can request the camera to record in landscape, but if the user happens to be holding the device in portrait anyway, the screen rotates to vertical during the transition, as my app releases control to the camera app. The camera app then receives control while the orientation is portrait and it doesn't like it and stops. The issue is not due to a change of orientation -- even if I keep everything locked to portrait throughout, the camera app cancels part-way through its initialization routine.

Is there a way to avoid this happening (while still using the camera via Intent)?

(PS I notice from here, about bespoke camera routines: "Note: A camera preview does not have to be in landscape mode..." and goes on to explain how to make that happen. Does that mean that the "Intent" implementation does?)

解决方案

Is there a way to avoid this happening (while still using the camera via Intent)?

No.

More specifically, there are thousands of possible camera apps -- preloaded or installed by users -- that could claim to support ACTION_VIDEO_CAPTURE, and any of them can have bugs as this one does. There is no EXTRA_PLEASE_AVOID_BUGS that you can pass on the Intent to change that (though that'd be really cool...).

这篇关于MediaStore.ACTION_VIDEO_CAPTURE崩溃相机应用,如果设备是纵向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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