当我的应用在Google Nexus 7平板电脑上运行时,它返回false,无法检测到设备是否配备了相机。
PackageManager pm = this.getPackageManager();
if(!pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
// disable camera button
}
现在我意识到Nexus 7没有预装相机应用程序,但是当我尝试启动相机活动时,我使用以下内容(以给用户选择替代应用程序的选项)。
File fTempCameraFullDirPath = new File(msTempCameraFullDirPath);
Uri outputFileUri = Uri.fromFile( fTempCameraFullDirPath );
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
startActivityForResult(Intent.createChooser(cameraIntent, getString(R.string.select_camera_app)), REQUEST_CODE_CAMERA);
很明显,我无法进入此代码,因为相机测试失败并禁用了按钮,但只要我在Nexus 7平板电脑上安装了相机应用程序,我应该能够拍照。
有人知道我可以使用哪种替代测试来在此平板电脑(或类似设备)上启用此功能吗?