I need to detect if the phone has a front facing camera, and if so, I need to calculate the megapixels. The same thing goes for a rear facing camera.
I know how to get the megapixels of a "Camera" object, but I don't know how to check for the other things.
P.s.: I would also be nice if you know a way to check if the Camera has flash or not, and other cool statistics about the camera
I always try to create helpers check if you have a front Camera:
public static boolean checkCameraFront(Context context) {
if(context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT)) {
return true;
} else {
return false;
}
}
Check if you have Camera in your device
public static boolean checkCameraRear() {
int numCamera = Camera.getNumberOfCameras();
if(numCamera > 0) {
return true;
} else {
return false;
}
}
http://developer.android.com/reference/android/hardware/Camera.html#getNumberOfCameras() , introduced in API lvl 9. This gets you the number of cameras
http://developer.android.com/reference/android/hardware/Camera.CameraInfo.html contains information of its facing direction.
http://developer.android.com/reference/android/hardware/Camera.Parameters.html#getPictureSize() is megapixels, if counted
http://developer.android.com/reference/android/hardware/Camera.Parameters.html#getFlashMode() returns null if no flash..
many other parameters can be gotten from the camera object too
http://developer.android.com/reference/android/hardware/Camera.html has step by step instructions for using camera. You can follow these instructions if you understand any object oriented language.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With