Bluetooth Low Energy (BLE), available in Android 4.3 and higher, creates short connections between devices to transfer bursts of data. BLE remains in sleep mode when not connected. This lets BLE provide lower bandwidth and reduced power consumption compared to Classic Bluetooth. BLE is ideal for apps such as a heart-rate monitor or a wireless keyboard. To use BLE, devices need to have a chipset that supports BLE.
Implementation
All current BLE app profiles are based on the Generic Attribute (GATT) Profile . When an Android-powered device interacts with a BLE device, the device that sends information is the server and the device that receives information is the client. Android includes developer APIs for BLE, including APIs for interactions between GATT servers and GATT clients. To take full advantage of the BLE APIs, implement the Android Bluetooth HCI Requirements.
Device modes
When using BLE, an Android-powered device can act as a peripheral device, a central device, or both. Peripheral mode lets devices send advertisement packets. Central mode lets devices scan for advertisements. An Android device acting as both a peripheral and central device can communicate with other BLE peripheral devices while sending advertisements in peripheral mode. Devices supporting Bluetooth 4.1 and lower can use BLE only in central mode. Older device chipsets might not support BLE peripheral mode.
BLE scanning
An Android-powered device can target and scan for specific Bluetooth devices more efficiently when using BLE. BLE APIs let app developers create filters for finding devices with less involvement from the host controller.
Location scanning
A device's location services can use Bluetooth to detect Bluetooth beacons and provide a more accurate location. This is how users enable the feature:
- Go to Settings > Security & Location > Location.
- Check that the Location On/Off toggle is in the On position.
- Go to Mode.
- Select either High accuracy or Battery saving mode.
In Android 11 and lower, individual apps require location permissions to use BLE scanning, even if they're scanning only to find devices to connect to. If the user disables location scanning, or doesn't grant an app location permissions, then the app won't receive any BLE scanning results.
In Android 12 and higher, the
BLUETOOTH_SCAN
,
BLUETOOTH_ADVERTISE
, and
BLUETOOTH_CONNECT
permissions can allow apps to scan
for nearby devices without needing to request the location permission.
For more information, see
Bluetooth permissions.
Users can disable system-level Bluetooth background scanning by going to Settings > Security & Location > Location > Scanning and clicking the Bluetooth scanning toggle to the off position. This doesn't affect BLE scanning for location or local devices.
Filter scan results
Android 6.0 and higher includes BLE scanning and filter-matching on the Bluetooth controller. A device can filter scan results and report found and lost events related to BLE devices to the application processor (AP). Filtering also works for batch scans, which helps save power as the device offloads BLE scanning to the firmware. Batch scans reduce how often the AP wakes up due to BLE scanning for devices or beacons.
The OnFound
/OnLost
feature is implemented
in the Bluetooth controller and then tested to confirm that BLE
devices aren't missed in scans. This provides power savings, and it
can also provide the following benefits:
- For an
OnFound
event, the main AP wakes up upon the discovery of a specific device. - For an
OnLost
event, the AP wakes up when a specific device can't be found. - Framework apps get fewer unwanted notifications when a nearby device is in range.
- Continuous scans enable framework apps to be notified when a device is out of range.
A scan filter can be based on the discovery of a device's
advertisements (the OnFound
event). The Java layer can
specify parameters such as first discovery (or a specified number of
advertisements since first discovery). Implement BLE filtering using
the
Advertising Packet Content Filter HCI command.