How to use camera flash/led as torch on a Samsung Galaxy Tab?

前端 未结 4 916
孤独总比滥情好
孤独总比滥情好 2020-12-02 12:59

I\'m facing to a problem with a Samsung Galaxy Tab. I want to use the camera flash as torch.

Does anyone know how to enable it ?

Hereby a code that works to

4条回答
  •  温柔的废话
    2020-12-02 13:17

    This is how I made it work.

    if (Build.MODEL.equals("GT-P1000")) {
    
                Log.d(FlashlightActivity.TAG, "This is Samsung Galaxy Tab.");
    
                params.setFlashMode(Parameters.FLASH_MODE_ON);
                camera.setParameters(params);
                camera.startPreview();
                camera.autoFocus(new AutoFocusCallback() {
                    public void onAutoFocus(boolean success, Camera camera) {
                    }
                });
    
                isLEDturnedOn = true;
                Log.d(FlashlightActivity.TAG, "LED turned ON.");
    
    } 
    

提交回复
热议问题