Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Nexus 7 indicating it has no 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 realize that the Nexus 7 doesn't ship with a built in camera app, but when I do try to launch a camera activity I use the following (to give the user the option to pick alternate apps).

    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 clearly I don't get to this code because the test for a camera fails and I disable the button, but it seems like as long as I have a camera app installed on my Nexus 7 table that I should be able to take pictures.

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

like image 758
Bryant Harris Avatar asked Dec 01 '22 21:12

Bryant Harris


2 Answers

You can check for FEATURE_CAMERA_FRONT, as the Nexus 7 only has a front-facing camera.

like image 160
Jan Gerlinger Avatar answered Dec 10 '22 13:12

Jan Gerlinger


Try checking for PackageManager.FEATURE_CAMERA_FRONT as well as FEATURE_CAMERA, since the Nexus 7 only has the front-facing camera, and the Android camera selection algorithm defaults to the rear camera.

like image 22
olex Avatar answered Dec 10 '22 12:12

olex