How to check if the device has front and rear cameras?

I need to determine if the phone has a front camera, and if so, I need to calculate megapixels. The same goes for the rear view camera.

I know how to get the megapixels of the Camera object, but I don’t know how to check other things.

Ps: I would also be nice if you knew how to check if the camera flashed or not, and other interesting information about the camera

+5
source share
2 answers

, :

public static boolean checkCameraFront(Context context) {
    if(context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT)) {
        return true;
    } else {
        return false;
    }
}

,

public static boolean checkCameraRear() {
    int numCamera = Camera.getNumberOfCameras();
    if(numCamera > 0) {
        return true;
    } else {
        return false;
    }
}
+2

All Articles