Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device has at least one camera pointing in some direction.
Constant Value: "android.hardware.camera.any"
Constant Value: "android.hardware.camera.any"
1. Get a PackageManager Instance and save to myPackageManager.
2. Create a Boolean Variable named bolCameraSupported.
3. Set the Minimum and Target SDK version to 17 or greater.
4. In the onCreate method, add the below code. This will return the any camera support to a boolean named bolCameraSupported. It will then display a toast displaying the camera existence on the device to the user.
bolCameraSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);
if (bolCameraSupported) {
Toast.makeText(this, "Device has at least 1 Camera", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No Camera on Device!", Toast.LENGTH_LONG).show();
}
5. Compile and run!
Resources:
http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_CAMERA_ANY
Resources:
http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_CAMERA_ANY