相机不会打开/关闭相机2的闪光灯

时间:2016-06-17 02:36:54

标签: android flashlight android-camera2

我需要帮助打开/关闭相机2的闪光灯。代码不起作用,拍照时不会打开闪光灯。我已经尝试了很多不同的方法但是做得很短。这是我的代码。请帮忙!

MainActivity.java

{
    ...
    "actions": {
        "SomeAction": {
            "conditions": [],
            "inputs": {
                "method": "post",
                "uri": "https://your-api.azurewebsites.net/api/YourMethod",
                "authentication": {
                    "tenant": "the-guid-for-your-tenant",
                    "audience": "the-guid-for-apiapp-azure-ad-application",
                    "clientId": "the-guid-for-logicapp-azure-ad-application",
                    "secret": "the-secret-for-logicapp-azure-ad-application",
                    "type": "ActiveDirectoryOAuth"
                }
            },
            ...

1 个答案:

答案 0 :(得分:0)

我在Camera2上使用此功能作为火炬

@TargetApi(Build.VERSION_CODES.M)
public void toggleMarshmallowFlashlight(boolean enable) {
    try {
        final CameraManager manager = (CameraManager) mContext.getSystemService(Context.CAMERA_SERVICE);
        final String[] list = manager.getCameraIdList();
        manager.setTorchMode(list[0], enable);
    } catch (CameraAccessException e) {
    }
}