Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CONSULTATION CASE OF USE #164

Open
Beckmann0o opened this issue Oct 21, 2024 · 2 comments
Open

CONSULTATION CASE OF USE #164

Beckmann0o opened this issue Oct 21, 2024 · 2 comments
Labels
question Further information is requested

Comments

@Beckmann0o
Copy link

Hi guys. Good afternoon !
I am facing a requirement in which I must integrate my mobile app with a BLE bracelet, basically I need to ensure that my application can scan BLE devices, looking for a BLE packet pre-configured on the bracelet, if the packet is detected, The application will trigger a panic event.
The doubt I have is the following. When the mobile device locks, that is, the screen turns off, the library has the ability to still continue performing periodic scans, for example every 30 seconds, scan for 10 seconds. I wanted to know if there is a possibility of integrating this liberia with a foreground service on Android. Thank you !!

Greetings from Argentina.

@philips77
Copy link
Member

philips77 commented Oct 21, 2024

Hello Argentina!

The best way to scan in background is by using this API:
https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#startScan(java.util.List%3Candroid.bluetooth.le.ScanFilter%3E,%20android.bluetooth.le.ScanSettings,%20android.app.PendingIntent)
It is working on Android Oreo and newer. You register a PendingIntent to a list of ScanFilters. When a matching device is found the Intent will be fired, no matter if your app was killed or not. This is the most "battery friendly" way.
You may also start a foreground service of type connectedDevice (I think) and scan more actively. You may configure the effectiveness of scan using setScanMode in ScanSettings.Builder.

Greetings from Poland!

@philips77 philips77 added the question Further information is requested label Oct 21, 2024
@Beckmann0o
Copy link
Author

Thank you very much for answering, it is very good to have the support of someone so experienced, thank you very much, I will try to implement the proposed api. Greetings from Argentina.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants