# Android BLE in the background: scanning, Doze and services
URL: https://alexmitrovic.com/blog/android-ble-background-scanning
Last updated: 2026-11-29

> Why Android BLE scans and sync stop in the background: throttling, screen-off limits, Doze, vendor battery savers, and what to use instead.

[Permissions & scanning](https://alexmitrovic.com/blog#permissions-scanning)

# BLE in the background on Android: scanning limits, Doze and foreground services

Why Android BLE scans and sync stop in the background: throttling, screen-off limits, Doze, vendor battery savers, and what to use instead.

By [Alex Mitrovic](https://alexmitrovic.com/about)Published 29 November 20264 min read

## On this page

1. [Which limits apply to BLE in the background?](https://alexmitrovic.com/blog/android-ble-background-scanning#limits)
2. [Finding devices in the background](https://alexmitrovic.com/blog/android-ble-background-scanning#find)
3. [Keeping a connection alive](https://alexmitrovic.com/blog/android-ble-background-scanning#keep)
4. [Periodic sync without a live connection](https://alexmitrovic.com/blog/android-ble-background-scanning#sync)
5. [Vendor battery managers](https://alexmitrovic.com/blog/android-ble-background-scanning#vendors)
6. [FAQ](https://alexmitrovic.com/blog/android-ble-background-scanning#faq)
7. [Sources](https://alexmitrovic.com/blog/android-ble-background-scanning#sources)

**Stuck on this in a real app?** I fix it on real phones, usually within a week.

[Book a free call](https://alexmitrovic.com/contact)

Short answer

Android limits background BLE in several layers: more than five scan starts in 30 seconds are throttled, unfiltered scans stop while the screen is off, long scans are downgraded, Doze delays work, and some vendors kill background apps. Use filtered scans, PendingIntent scans or CompanionDeviceManager to find devices, and a foreground service of type connectedDevice to keep a connection alive.

## Key takeaways

- Never start and stop scans in a tight loop: five starts in 30 seconds and Android silently ignores the next one.
- Always scan with a ScanFilter if you need results with the screen off.
- A PendingIntent scan survives your process being killed; the system wakes you with results.
- To keep a live connection in the background, use a foreground service with type connectedDevice.
- Test on Samsung and Xiaomi phones with battery optimization on; that's where background BLE dies first.

“It works when the app is open” is the second most common BLE bug report after drops. Background BLE on Android isn't one limit but a stack of them, added over several releases, and on top of that each phone vendor has its own battery manager. Here they are in the order they bite, and what to use instead.

## Which limits apply to BLE in the background?

| Limit | Since | What happens | What to do
| Scan start throttling | Android 7 | More than 5 `startScan` calls in 30 s: later ones silently don't start | Start one long scan; don't restart it to “refresh” results
| Long-running scans | Android 7 | A scan running for about 30 minutes is downgraded to opportunistic | Use filters and PendingIntent scans for long waits
| Screen-off unfiltered scans | Android 8.1 | Scans without a `ScanFilter` stop while the screen is off | Always pass at least one filter: service UUID, name or address
| Background execution limits | Android 8 | Background services are stopped soon after the app leaves the foreground | Foreground service, WorkManager, or system-delivered scan results
| Doze and App Standby | Android 6 | Network, alarms and jobs are deferred when the phone is idle | Plan for delays; don't rely on exact timing in the background
| Foreground service types | Android 14 | A foreground service must declare a type and hold its permissions | `connectedDevice` type + `FOREGROUND_SERVICE_CONNECTED_DEVICE`
| Vendor battery savers | Any | Some phones kill or freeze background apps far more aggressively | Test on those phones; guide users to exemptions only when needed

## Finding devices in the background

There are three good ways to learn that a device is nearby without keeping your app awake:

### 1. A filtered scan with a PendingIntent

Since Android 8, `startScan` can take a `PendingIntent` instead of a callback. The system keeps scanning, using hardware filters where the chip supports them, and delivers matching results to a `BroadcastReceiver`, even if your process was killed in the meantime.

A background scan that survives process death

```
@SuppressLint("MissingPermission") // BLUETOOTH_SCAN checked before calling
fun startBackgroundScan(context: Context) {
    val filters = listOf(
        ScanFilter.Builder().setServiceUuid(ParcelUuid(MY_SERVICE_UUID)).build()
    )
    val settings = ScanSettings.Builder()
        .setScanMode(ScanSettings.SCAN_MODE_LOW_POWER)
        .setCallbackType(ScanSettings.CALLBACK_TYPE_FIRST_MATCH)
        .build()
    val intent = PendingIntent.getBroadcast(
        context, 1, Intent(context, ScanResultReceiver::class.java),
        PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE // the system adds results
    )
    context.getSystemService(BluetoothManager::class.java)
        .adapter.bluetoothLeScanner.startScan(filters, settings, intent)
}
```

The receiver gets the results in `BluetoothLeScanner.EXTRA_LIST_SCAN_RESULT`. Keep the work in it short: start a foreground service or enqueue work if you need to connect.

### 2. CompanionDeviceManager presence

If the app is associated with the device through `CompanionDeviceManager`, newer Android versions can tell your `CompanionDeviceService` when the device appears and disappears, and associated apps get exemptions for starting foreground services from the background. For single-device companion apps this is the most battery-friendly option.

### 3. autoConnect to a known device

For a device you've connected to before, `connectGatt(context, true, …)` registers a background connection that the controller completes when the device shows up. It only lives as long as your process, so combine it with a foreground service if the app must stay connected.

## Keeping a connection alive

If the product needs a live link with the screen off (a sensor streaming data, a lock waiting for a command), the honest answer is a foreground service. It shows a notification, which is the point: the user can see the app is working for them.

Foreground service for a BLE connection (Android 14+ rules)

```
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<service
    android:name=".ble.DeviceConnectionService"
    android:exported="false"
    android:foregroundServiceType="connectedDevice" />
```

Two things trip people up. On Android 14+, starting the service with the `connectedDevice` type requires that you hold a matching runtime permission such as `BLUETOOTH_CONNECT`, or it throws. And since Android 12, apps mostly can't start a foreground service from the background, so start it while the app is visible, or rely on one of the exemptions (CDM association is one).

## Periodic sync without a live connection

Many devices only need a sync now and then: a sensor with a day of readings, a lock's access log. Use WorkManager: a periodic job (15 minutes is the minimum) that connects, syncs and disconnects. It's deferred in Doze and batched with other work, so don't promise exact times, but it's kind to the battery and survives reboots.

## Vendor battery managers

Stock Android is only half the story. Some vendors add their own “sleeping apps” lists, auto-start restrictions or aggressive task killers, and they differ between models and OS versions. [dontkillmyapp.com](https://dontkillmyapp.com/) keeps track of the known cases. My rule: first make the app work within the official rules (foreground service, filters, WorkManager), test on those phones, and only then, if a specific phone still kills it, show a short guide for that vendor's setting.

Add which phone brands gave you the most trouble in the background, and what you did about it.

## FAQ

### Why does my Android BLE scan stop when the screen turns off?

Since Android 8.1, scans without a ScanFilter are stopped while the screen is off. Add at least one filter, for example your device's service UUID, and the scan continues.

### Why does startScan sometimes find nothing on Android?

If the app called startScan more than five times in 30 seconds, Android silently ignores further starts for a while. Start one scan and keep it running instead of restarting it to refresh results.

### How do I keep a BLE connection alive in the background on Android?

Run the connection from a foreground service with foregroundServiceType="connectedDevice", declare FOREGROUND_SERVICE_CONNECTED_DEVICE, hold BLUETOOTH_CONNECT and show its notification. Start it while the app is visible.

### Can my app get BLE scan results after it was killed?

Yes, with a PendingIntent scan: startScan with a PendingIntent keeps running in the system and delivers matching results to your BroadcastReceiver, starting your process if needed.

## Sources

- [Android Developers: Find BLE devices](https://developer.android.com/develop/connectivity/bluetooth/ble/find-ble-devices)
- [Android Developers: BluetoothLeScanner.startScan with PendingIntent](https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner)
- [Android Developers: Foreground service types (connectedDevice)](https://developer.android.com/develop/background-work/services/fgs/service-types)
- [Android Developers: Optimize for Doze and App Standby](https://developer.android.com/training/monitoring-device-state/doze-standby)
- [Android Developers: Companion device pairing](https://developer.android.com/develop/connectivity/bluetooth/companion-device-pairing)
- [Don't kill my app! (vendor battery managers)](https://dontkillmyapp.com/)

**Written by Alex Mitrovic**, an Android and iOS developer who builds reliable apps for Bluetooth and IoT devices and tests every fix on real phones. If your app has this problem on phones you can't pin down, the [BLE reliability audit](https://alexmitrovic.com/services/ble-reliability-audit) finds out why in about a week. [About me](https://alexmitrovic.com/about) · [LinkedIn](https://www.linkedin.com/in/aleksmitro98/)

## Read next

[Article### Android 12+ Bluetooth permissions: BLUETOOTH_SCAN, CONNECT and location, done rightWhich Bluetooth permissions an Android BLE app needs per version: BLUETOOTH_SCAN, BLUETOOTH_CONNECT, neverForLocation and location, with a generator.](https://alexmitrovic.com/blog/android-12-bluetooth-permissions)

[Article### CoreBluetooth state restoration: keeping an iOS BLE app connected in the backgroundHow an iOS BLE app keeps working in the background: the bluetooth-central mode, pending connections and state restoration, with Swift code.](https://alexmitrovic.com/blog/corebluetooth-state-restoration)

[Article### Android BLE connection drops: what status 8, 19 and 22 mean and how to fix themWhy Android BLE connections drop: what disconnect statuses 8, 19, 22 and 0x3D mean, how to tell them apart, and a reconnect policy that works.](https://alexmitrovic.com/blog/ble-connection-drops-android)

## Seeing this in your own app?

Send me the phone models and what the logs say. On a short call I'll tell you where I'd look first.

[Book a free call](https://alexmitrovic.com/contact)

Free · NDA on request · reply within 1–2 working days
