Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device includes a gyroscope.
Constant Value: "android.hardware.sensor.gyroscope"
Constant Value: "android.hardware.sensor.gyroscope"
Here are some examples of Android Cell phones with a Gyroscope.
1. Get a PackageManager Instance named myPackageManager.
1. Get a PackageManager Instance named myPackageManager.
2. Create a Boolean Variable named bolGyroSupported.
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 gyroscope feature availability to a boolean named bolGyroSupported. It will then display a toast displaying the gyroscope feature availability of the device to the user.
bolGyroSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_SENSOR_GYROSCOPE);
if (bolGyroSupported) {
Toast.makeText(this, "Device has a Gyroscope", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "Device does NOT have a Gyroscope!", Toast.LENGTH_LONG).show();
}
5. Compile and run!
Resources:
http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_SENSOR_GYROSCOPE
http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_SENSOR_GYROSCOPE