Google Nexus 7 indicates that it does not have a camera

When my app runs on a Google Nexus 7 tablet, it returns false for this standard Android test to see if the device is equipped with a camera.

PackageManager pm = this.getPackageManager(); if(!pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) { // disable camera button } 

Now I understand that Nexus 7 does not come with a built-in camera application, but when I try to start working with the camera, I use the following (to give the user the opportunity to choose alternative applications).

  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); 

Now itโ€™s clear that I donโ€™t get to this code because the camera test fails and I disabled the button, but it seems that while I have the camera application installed on my Nexus 7 table, I should be able to take pictures.

Does anyone know an alternative test that I can use to enable this feature on this tablet (or similar devices)?

+4
source share
4 answers

You can check FEATURE_CAMERA_FRONT , since the Nexus 7 only has a front camera.

+9
source

Try checking PackageManager.FEATURE_CAMERA_FRONT as well as FEATURE_CAMERA , since the Nexus 7 only has a front camera and the default Android camera selection algorithm is for the rear camera.

+4
source

How to update the answer:

Since API level 17 you can also check PackageManager.FEATURE_CAMERA_ANY , which indicates whether the device has any camera regardless of its position.

+4
source

Looking at the docs , he says that FEATURE_CAMERA refers to the camera facing away from the screen, which is the rear camera. Therefore, it should return false.

+1
source

Source: https://habr.com/ru/post/1437906/


All Articles