8.9. BLE Processing Sample Code
When developing a BLE app, describe the sample code used in the BLE API.
8.9.1. Enabling BLE
Call isEnable() and acquire the current status.
Since BLE is disabled when this function returns false, call enable() to enable BLE.
// Instance acquisition for the BLE manager class
BluetoothLeAdapterManager mManager = BluetoothLeAdapterManager.getInstance();
if ( ! mManager.isEnable() ) {
// BLE Off
if ( ! mManager.enable() ) {
//Error processing: display error message for BLE-On failure
}
} else {
// BLE On
}
8.9.2. Disabling BLE
Call isEnable() and acquire the current status.
Since BLE is enabled when this function returns true, call disable() to disable BLE.
// Instance acquisition for the BLE manager class
BluetoothLeAdapterManager mManager = BluetoothLeAdapterManager.getInstance();
if ( mManager.isEnable() ) {
// BLE On
if ( ! mManager.disable() ) {
//Error processing: display error message for BLE-Off failure
}
} else {
// BLE Off
}
MOVERIO Pro Developer's Guide (Rev.1.4)
168