A. 安卓手机下载什么可以检测有没有摄像头
360安全卫士、网络卫士、检测摄像头APP
B. 检查android是否具有摄像头
import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;
import android.os.Build;
public class CameraUtils {
/**
* 检测是否有前置摄像头
* @return
*/
public static boolean hasFrontFacingCamera() {
final int CAMERA_FACING_BACK = 1;
return checkCameraFacing(CAMERA_FACING_BACK);
}
/**
* 检测是否有后置摄像头
* @return
*/
public static boolean hasBackFacingCamera() {
final int CAMERA_FACING_BACK = 0;
return checkCameraFacing(CAMERA_FACING_BACK);
}
private static boolean checkCameraFacing(final int facing) {
if (getSdkVersion() < Build.VERSION_CODES.GINGERBREAD) {
return false;
}
final int cameraCount = Camera.getNumberOfCameras();
CameraInfo info = new CameraInfo();
for (int i = 0; i < cameraCount; i++) {
Camera.getCameraInfo(i, info);
if (facing == info.facing) {
return true;
}
}
return false;
}
public static int getSdkVersion() {
return android.os.Build.VERSION.SDK_INT;
}
}