简体   繁体   中英

Can a BLE peripheral connect to a background app on an Android phone?

I am working on an application where we will have a BLE peripheral with a button, and an App running on an Android phone. The user will manually pair the peripheral with the phone, and then the phone may go into standby, or be used for other purposes.

Can a button press on the BLE peripheral cause the phone to wakeup and open the App?

On a related note, if the phone is power cycled, can it be configured to automatically re-pair with the peripheral, without requiring any user action?

If the peripheral is power cycled, can it automatically re-pair with the phone, without requiring any user action?

All the answers are YES , with some custom algorithms.

However I have to remind that in Android 4.3, connecting without user interaction is extremely dangerous. Android 4.3 cannot cancel any outgoing connection due to a bug, and no callbacks for connection time out. If the peripheral goes out of range/ runs out of battery / simply malfunctions during the connection, the Bluetooth stack of your phone will just STUCK until you reboot your phone. If the connection is initiate by the user in the ui we can alert the user when it gets wrong, but if you start connection in the background automatically you may risk in breaking the Bluetooth without user understanding whats going on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM