Android Question Best practice for BLE when you need it to run even when the app is not visible?

tseyfarth

Member
Licensed User
Longtime User
Hello,

The app I am working on uses BLE to communicate with other devices. I started my project out with the sample code for BLE and have it working. However, now I need to incorporate that into a new version. I need the BLE to be active after the app starts whether visible or not, until the app is shut down.

I can add the code to the new projects B4XPages MainPage, but thought it would be cleaner if it were either in another class module or code module. The important thing is that it needs to be active after the app starts whether visible or not, until the app is shut down. I understand that if I put this code into the MainPage module, then it will stop running when the app is not visible.

What is the best way to do this?

Thanks,
Tim
 

tseyfarth

Member
Licensed User
Longtime User
Hello Erel,

Can this foreground service also be used in B4J since that is the platform I am working with before going to B4A or B4i?

Also, can the same concept be used for B4i? If so, what is that called?

Thanks,
Tim
 
Upvote 0
Top