How to detect cameras available on an Android device? and also if the device has a front camera how to use it?

advertisements

How to detect no of camera's available in android device? and also if the device has front camera how to use it?


What I would suggest is similar to doc_180's answer, but should be able to detect both front and back facing cameras even for Froyo, though if I'm not mistaken, Froyo never supported front-facing cameras, so you'll always get a false response for frontCam on Froyo.

PackageManager pm = getPackageManager();
boolean frontCam, rearCam;

//Must have a targetSdk >= 9 defined in the AndroidManifest
frontCam = pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
rearCam = pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);

EDIT: Just realized this is a really, really old question. Oh well, hopefully it helps someone in the future.