通过PackageManager可以判断android设备是否有相机
代码如下 | 复制代码 |
PackageManager pm = getPackageManager(); // FEATURE_CAMERA - 后置相机 // FEATURE_CAMERA_FRONT - 前置相机 if(!pm.hasSystemFeature(PackageManager.FEATURE_CAMERA) && !pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT)) { Log.i("camera","non-support"); }else{ Log.i("camera","support"); } |