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