Turn ON/OFF Camera LED/flash light in Samsung Galaxy Ace 2.2.1 & Galaxy Tab

孤者浪人 提交于 2019-12-28 02:44:14

问题


I am turning ON Camera LED light using FLASH_MODE_ON.

Samsung Galaxy Ace have only three flash modes : on, off and auto.

FLASH_MODE_TORCH not working in Samsung Galaxy Tab & Samsung Galaxy Ace 2.2.1

Here is my code how i am turning ON my Camera LED

    Camera cam;
    cam = Camera.open();     
    Parameters params = cam.getParameters();
    params.setFlashMode(Parameters.FLASH_MODE_ON);
    cam.setParameters(params);
    cam.startPreview();
    cam.autoFocus(new AutoFocusCallback() {
                public void onAutoFocus(boolean success, Camera camera) {
                }
     });

And turning it off by using :

cam.stopPreview();
cam.release();

Code Reference : Use camera flashlight in Android

But the problem is LED Light remains on just for 5sec. It just then turns OFF automatically.

Can anyone please tell where can be the problem. OR any way to turn ON the LED light continuously till its requested to Stop.


回答1:


I will soon released a new version of my app to support to galaxy ace.

You can download here: https://play.google.com/store/apps/details?id=droid.pr.coolflashlightfree

In order to solve your problem you should do this:

this._camera = Camera.open();     
this._camera.startPreview();
this._camera.autoFocus(new AutoFocusCallback() {
public void onAutoFocus(boolean success, Camera camera) {
}
});

Parameters params = this._camera.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_ON);
this._camera.setParameters(params);

params = this._camera.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_OFF);
this._camera.setParameters(params);

don't worry about FLASH_MODE_OFF because this will keep the light on, strange but it's true

to turn off the led just release the camera



来源:https://stackoverflow.com/questions/6939816/turn-on-off-camera-led-flash-light-in-samsung-galaxy-ace-2-2-1-galaxy-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!