capacitor-community / capacitor-community/bluetooth-le

Scanning in background in Android should use a Pending Intent

Open
#699 4 comments 0 reactions 0 assignees View on GitHub
android bug
Dominant language
TypeScript
Stars
360
Forks
121
Avg merge
10d 45m
Merged PRs (30d)
2

Description

**Describe the bug**
The current implementation does not allow connecting to BLE device after the app is backgrounrded

**To Reproduce**
Steps to reproduce the behavior:
1. Launch a BLE Scan
2. Close device screen
3. Broadcast on BLE device
4. Wait forever

**Expected behavior**
The app should find the device in the background

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Plugin version:**
- @capacitor-community/bluetooth-le: v6.0.1

**Additional context**
https://developer.android.com/develop/connectivity/bluetooth/ble/background

In android, to receive scan results in the background, the startScan method should be called with a Pending Intent and not a ScanResult

See https://github.com/android/platform-samples/blob/main/samples/connectivity/bluetooth/ble/src/main/java/com/example/platform/connectivity/bluetooth/ble/BLEScanIntentSample.kt#L114-L120 for an official example

Contributor guide

Open the contributing guide

Research direction

Start at the Android BLE scanning implementation and its startScan entry point, then compare the current ScanResult-based call with the official BLEScanIntentSample.kt example linked in the issue. Done means BLE scan results can be received and the device is found after the app is backgrounded.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, typescript
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.