Android Question bluetooth device control during run

tango

Member
Licensed User
bluetooth device attached and initialize it,that device run. but when power off it and power on again during app run ,that device not running. how can we solve to control it and if error then re initilize it again with timer or service
 

lemonisdead

Well-Known Member
Licensed User
bluetooth device attached and initialize it,that device run. but when power off it and power on again during app run ,that device not running. how can we solve to control it and if error then re initilize it again with timer or service
If I do well understand your question : you will have to watch the disconnection of the Bluetooth device to be able to reconnect it. I would use some intent filters in the manifest

B4X:
AddReceiverText(Service1, <intent-filter>
    <action android:name="android.bluetooth.device.action.ACL_CONNECTED"/>
    </intent-filter>)
AddReceiverText(Service2, <intent-filter>
    <action android:name="android.bluetooth.device.action.ACL_DISCONNECTED"/>
    </intent-filter>)
Each service should be started when the connection or disconnection happens. Then using the Serial library you should be able to retrieve the device connected or reconnect to it when powered.
 
Top