如果S4设备上使用闪光灯自定义相机PictureCallback不运行 [英] Custom Camera PictureCallback does not run if flash used on S4 devices

查看:138
本文介绍了如果S4设备上使用闪光灯自定义相机PictureCallback不运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写我最近改为使用闪光灯(如果有的话)设备上的一个基本的自定义相机。一旦我做出了改变code跑了罚款和以前一样对我的HTC One迷你2,但在我的Galaxy S4不再奏效。步进通过我发现我的JPEG回调从不在S4达到,而不是原始回调运行,但空字节[]提供。

I have written a basic custom camera which I recently changed to use the flash (where available) on the device. Once I had made the change the code ran fine as before on my HTC One Mini 2, but no longer worked on my Galaxy S4. After stepping through I found my jpeg callback is never reached on the S4, instead the raw callback is run but with a null byte[] supplied.

我发现这个类似的问题:
<一href=\"http://stackoverflow.com/questions/21929905/galaxy-s4-turn-on-camera-flash-cause-onpicturetaken-not-get-called#comment41912741_21929905\">S4闪光问题

I found this similar question: S4 Flash Problem

这似乎证实有这些设备上的问题和解决方案,但该解决方案还没有被记录在案。

Which seems to confirm there is an issue and solution on these devices but the solution has not been documented.

再次重申,在code作用于S4罚款,只要我不打开闪光灯:

To re-iterate, the code works fine on the S4 so long as I don't turn on the flash with:

Camera.Parameters p = mCamera.getParameters();
p.setFlashMode(Camera.Parameters.FLASH_MODE_AUTO);//Or FLASH_MODE_ON
mCamera.setParameters(p);

有人用这些设备上的经验可以提供解决方案?

Can anybody with experience on these devices provide the solution?

推荐答案

大量的试验和错误的过去一周我都在两种可能的解决方案,迷迷糊糊的这个问题后,其中第一个没有任何意义我在所有:

After a lot of trial and error over the last week I have stumbled upon two possible solutions to this problem, the first of which doesn't make any sense to me at all:


  1. 强制变焦比X1更大。出于某种原因,如果我设置变焦X1.2等相机再次工作,因为我期望的那样。

  1. Force the zoom to be greater than x1. For some reason if I set the zoom to x1.2 etc. the camera works again as I would expect.

确保所选择的图像尺寸的长宽比设备的原始宽高比。该S4拥有1920×1080,这样匹配这个16中的任何图片大小的分辨率:9比例可与闪光灯。这使得更多的意义,但是为什么闪光灯使不支持应该getSupportedPictureSizes()我不知道(尽管他们似乎是不使用闪光灯。)

Ensure the aspect ratio of the selected picture size matches the native aspect ratio of the device. The S4 has a resolution of 1920x1080 so any picture size that matches this 16:9 ratio works with the flash on. This makes a bit more sense but why the flash makes the difference and why anything that isn't supported should be returned by getSupportedPictureSizes() I don't know (albeit they do seem to be without the flash.)

目前我选择使用选项2和我在我的其他设备进行测试。
也可能是值得一提的是我在S4下一步是允许用户/自动开启闪光灯开/关,但这一要求的破坏,每次重新相机。

Currently I have chosen to use option 2 and am testing on my other devices. Might also be worth mentioning that my next step on the S4 was to allow the user to turn the flash on/off/auto themselves but this required destroying and recreating the camera each time.

这篇关于如果S4设备上使用闪光灯自定义相机PictureCallback不运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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