Search code examples
androidcameraandroid-2.2-froyokindle-firekindle

Determining if camera exists for Kindle


I'm trying to determine whether a particular Android device has a camera. The documentation for the android.hardware.Camera.open() states

Creates a new Camera object to access the first back-facing camera on the device. If the device does not have a back-facing camera, this returns null.

The Kindle I am testing on (first generation I believe) does not have any camera, and yet open() is returning non-null. Why is that? Perhaps because Amazon runs a forked version of Android with different behavior? Is there another way to determine whether or not the device has a camera?


Solution

  • Maybe this can help you

    /**
     * Determines if the current device can handle an image capture action.
     * @return true if the device can handle an image capture action. False if it cannot.
     */
    protected boolean canHandleCameraIntent() {
      final Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
      final List<ResolveInfo> results = getPackageManager().queryIntentActivities(intent, 0);
      return (results.size() > 0);            
    }
    

    more content at https://developer.amazon.com/sdk/fire/specifications.html

    Update

    I can't test that for you, but I think this could also help you

    http://developer.android.com/reference/android/content/pm/PackageManager.html

    PackageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);