@Override
        public void onReceive(final Context context, final Intent intent) {
            final String action = intent.getAction();
            Log.i(TAG, "Received Action:" + action);

            if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) {
                updateConnectionState(State.CONNECTED);
                invalidateOptionsMenu();
            } else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) {
                clearUI();
                updateConnectionState(State.DISCONNECTED);
                invalidateOptionsMenu();
            } else if (BluetoothLeService.ACTION_GATT_CONNECTING.equals(action)) {
                clearUI();
                updateConnectionState(State.CONNECTING);
                invalidateOptionsMenu();
            } else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
                // Show all the supported services and characteristics on the user interface.
                displayGattServices(mBluetoothLeService.getSupportedGattServices());
            } else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
                final String uuid = intent.getStringExtra(BluetoothLeService.EXTRA_UUID_CHAR);
                final byte[] dataArr = intent.getByteArrayExtra(BluetoothLeService.EXTRA_DATA_RAW);

                view.setGattUuid(uuid);
                view.setData(dataArr);
            }
        }
For a given BLE device, this Activity provides the user interface to connect, display data,
and display GATT services and characteristics supported by the device.  The Activity
communicates with {@code BluetoothLeService}, which in turn interacts with the
Bluetooth LE API.
sample_app/src/main/java/uk/co/alt236/btlescan/ui/control/DeviceControlActivity.java