Android Question Bluetooth Background Service

sortec.nick

Member
Licensed User
Longtime User
Hello, I'm developing on a Samsung Galaxy S4, and I have been struggling with Bluetooth and getting it to work more than one compilation per reset.

I have a Bluetooth device that needs to be connected to the phone as permanently as possible. This device sends results in a comma delimited datastring over Bluetooth. I think I might need to have Bluetooth managed by a Background service.

My application works fine when the phone is reset and run, but as I'm developing the app, and run it using the Debug (legacy) mode, the Bluetooth stops working to the point that Bluetooth switches off outside the application, which I view from the settings screen. From here, I can't get it to turn back on until the phone is reset.

To confirm that this problem it is not device specific I have replicated the behaviour over four different Galaxy S4 handsets.

My hunch is that the problem might be that my application spans a number of activities, but the Serial object is initialised and manipulated in only one root activity, who's child activities then respond to the device's Bluetooth communications.

I'm struggling to get my head around Bluetooth, and wondered if a Bluetooth expert might have a template class that I might be able to use that if a Bluetooth connection is lost then it will reconnect automatically.

I have tested the Bluetooth device with some Bluetooth debugger apps that I have found, and they are far more reliable than my program. I have tried: BTClient, Bluetooth and Wifi, Bluetooth spp pro and Bluetooth device.

Please accept my apology if this doesn't make much sense. I'm trying to describe the problem as well as I can. I appreciate that there might be no experts out there, but any help will be most appreciated and it is in my interests to help develop the Bluetooth functionality in B4A overall if need be.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top