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