Check if this device only supports LEGACY mode operation in the Camera2 API for the given camera ID. - Android android.hardware

Android examples for android.hardware:Camera ID

Description

Check if this device only supports LEGACY mode operation in the Camera2 API for the given camera ID.

Demo Code

import android.content.Context;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager;

public class Main{

    /**/*w  ww.j av  a 2s .  co m*/
     * Returns {@code true} if this device only supports {@code LEGACY} mode operation in the
     * Camera2 API for the given camera ID.
     *
     * @param context {@link Context} to access the {@link CameraManager} in.
     * @param cameraId the ID of the camera device to check.
     * @return {@code true} if this device only supports {@code LEGACY} mode.
     */
    public static boolean isLegacyHAL(Context context, int cameraId)
            throws Exception {
        CameraManager manager = (CameraManager) context
                .getSystemService(Context.CAMERA_SERVICE);
        CameraCharacteristics characteristics = manager
                .getCameraCharacteristics(Integer.toString(cameraId));

        return characteristics
                .get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL) == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY;
    }

}

Related Tutorials