Feature for getSystemAvailableFeatures() and hasSystemFeature(String)
The device's display has a touch screen.
Constant Value: "android.hardware.touchscreen"
1. Get a PackageManager Instance named myPackageManager.
Constant Value: "android.hardware.touchscreen"
1. Get a PackageManager Instance named myPackageManager.
2. Create a Boolean Variable named bolTouchScreenSupported.
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 touch screen ability to a boolean named bolTouchScreenSupported. It will then display a toast displaying the touch screen ability of the device to the user.
bolTouchScreenSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN);
if (bolTouchScreenSupported) {
Toast.makeText(this, "Device has Touch Screen capability", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No Touch Screen capability!", Toast.LENGTH_LONG).show();
}
5. Compile and run!