设置Parameters.FLASH_MODE_TORCH不会对Droid X的2.3工作 [英] Setting Parameters.FLASH_MODE_TORCH doesn't work on Droid X 2.3

查看:397
本文介绍了设置Parameters.FLASH_MODE_TORCH不会对Droid X的2.3工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写设置闪光模式火炬的应用程序。我一直对我的Droid X的测试应用程序,并且LED指示灯不亮。我试了一下在Droid难以置信,它工作得很好。我想不通的问题是什么。这里是我的code的一部分,打开手电筒模式。

I am writing an app that sets the flash mode to torch. I have been testing the application on my Droid X, and the LED light does not come on. I tried it on a Droid Incredible and it worked fine. I can't figure out what the problem is. Here is part of my code for turning on torch mode.

    Camera mCamera = Camera.open();
    Camera.Parameters params = mCamera.getParameters();
    if(params.getFlashMode() != null){
        params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
    }
    mCamera.setParameters(params);

我已经加入mCamera.start preVIEW();因为我读了应该有所作为,但事实并非如此。我还做了可用闪光模式的列表,并将其显示在屏幕上,以确保我的Droid X的确实有手电筒模式,这是在列表中。我甚至创造从code一个新的应用我在网上找到了开启和关闭按钮的LED闪光灯。同样它工作得很好的Droid难以置信,但不是在Droid X.有我丢失的东西得到这个上对Droid X上运行,或可以与姜饼的东西吗?在Droid X运行姜饼和Droid难以置信运行升级Froyo。

I have added mCamera.startPreview(); because I read that should make a difference, but it doesn't. I also made a list of available flash modes and displayed them to the screen to make sure that my Droid X does have torch mode, and it was in the list. I even created a new application from code I found online that turns the LED flash on and off with a button. Again it worked fine on the Droid Incredible but not the Droid X. Is there something I am missing to get this to run on the Droid X, or could it be something with Gingerbread? The Droid X is running Gingerbread and the Droid Incredible is running FroYo.

推荐答案

有不少怪癖设置FLASH_MODE_TORCH时。

There are quite a few quirks when setting FLASH_MODE_TORCH.

通常你需要开始一个摄像头preVIEW:

Often you need to start a camera preview:

Camera mCamera = Camera.open();
mCamera.startPreview();
Camera.Parameters params = mCamera.getParameters();
if(params.getFlashMode() != null){
    params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
}
mCamera.setParameters(params);

这可能会解决它的一些手机,其他手机也需要preVIEW被吸引到一个SurfaceView。这可以通过在活动实施SurfaceHolder.Callback界面来完成。
看一个例子<一个href=\"http://$c$c.google.com/p/torch/source/browse/trunk/src/com/colinmcdonough/android/torch/Torch.java\"相对=nofollow>这里。

That may resolve it on some phones, other phones also require the preview to be drawn to a SurfaceView. This can be done by implementing SurfaceHolder.Callback interface in your activity. See an example here.

这篇关于设置Parameters.FLASH_MODE_TORCH不会对Droid X的2.3工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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