How to Determine if Android Device has Barometer Sensor Feature

public static final String FEATURE_SENSOR_BAROMETER was added in API level 9
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device includes a barometer (air pressure sensor.)
Constant Value: "android.hardware.sensor.barometer"
Here are some examples of cell Phones with Barometers.


1. Get a PackageManager Instance named myPackageManager.

2. Create a Boolean Variable named bolBarometerSupported

3. Set the Minimum and Target SDK version  to or greater. 

4. In the onCreate method, add the below code. This will return the barometer sensor ability to a boolean named bolBarometerSupported. It will then display a toast displaying the barometer sensor ability of the device to the user.

bolBarometerSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_SENSOR_BAROMETER);
if (bolBarometerSupported) {
Toast.makeText(this, "Device has Barometer Sensor capability", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No barometer Sensor capability!", Toast.LENGTH_LONG).show();
}

5. Compile and run!