android 推断手机是否支持前置摄像头

话不多说 直接上代码,

@SuppressLint("NewApi")
public static boolean isSupportFrontCamera() {
if (!hasGingerbread()) {
return false;
}
@SuppressWarnings("deprecation")
int numberOfCameras = android.hardware.Camera.getNumberOfCameras();
if (2 == numberOfCameras) {
return true;
}
return false;
}
public static boolean hasGingerbread() {
       return Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD;
   }

搞定

原文地址:https://www.cnblogs.com/mthoutai/p/7064815.html