Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device is capable of communicating with other devices via Bluetooth.
Constant Value: "android.hardware.bluetooth"
1. Get a PackageManager Instance named myPackageManager.
Constant Value: "android.hardware.bluetooth"
1. Get a PackageManager Instance named myPackageManager.
2. Create a Boolean Variable named bolBluetoothSupported.
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 Bluetooth ability to a boolean named bolBluetoothSupported. It will then display a toast displaying the Bluetooth ability of the device to the user.
bolBluetoothSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
if (bolBluetoothSupported) {
Toast.makeText(this, "Device has Bluetooth capability", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No Bluetooth capability!", Toast.LENGTH_LONG).show();
}
5. Compile and run!
Resources:
http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_BLUETOOTH
http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_BLUETOOTH