Using android.hardware.camera2

For some reason, Android Studio cannot find a new camera library: android.hardware.camera2

Do you have any suggestions? The code is as follows:

enter image description here

+4
source share
3 answers

This is because you camera2are the name of the package, not the name of the class.

see this link

You must call import android.hardware.camera2.*;to import all calss from camera2Api

+8
source

There is no camera class in the new camera package ie android.hardware.camera2. To use the camera class, use the legacy android.hardware.Camera package.

+1
source
import android.hardware.camera2.*;

Camera camera; //this one uses android.hardware.Camera.*;

. android.hardware.Camera android.hardware.camera2.

These are some examples of classes available on camera2 that will be used in the new API 21 +

import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CameraMetadata;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.TotalCaptureResult;
import android.hardware.camera2.params.StreamConfigurationMap;
+1
source

All Articles