#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Service_Create
mod_functions.writelog("svc_bt_acl_connected(),Service_Create")
End Sub
Sub Service_Start (StartingIntent As Intent)
mod_functions.writelog("svc_bt_acl_connected(),Service_Start")
' // we can restart the svc_event_handler from here after we have been woken up
If Not(IsPaused(svc_serial)) Then
mod_functions.writelog("svc_bt_acl_connected(),Service_Start, svc_serial is running, call remote_connect")
CallSub(svc_serial,"remote_connect")
Else
mod_functions.writelog("svc_bt_acl_connected(),Service_Start, Starting svc_serial")
StartService(svc_serial)
End If
' // no need to keep this alive
StopService("")
End Sub
Sub Service_Destroy
mod_functions.writelog("svc_bt_acl_connected(),Service_Destroy")
End Sub
#
Sub Service_Start (StartingIntent As Intent)
mod_functions.writelog("svc_serial(),Service_Start ")
pw.PartialLock
com_listen
tmrServiceHook.Enabled = True
End Sub
Sub Service_Destroy
mod_functions.writelog("svc_serial(),Service_Destroy")
pw.ReleasePartialLock
End Sub
What is the service name? If is is not s2 then you need to update the manifest text.My codes are of no errors before. But after I added the lines that you want us to add, the error message I get is: "Module:s2_br not found". How come?
I have added these lines. One to the code itself. And one to the manifest editor. I also declared this following codes:
Dim admin As BluetoothAdmin
Dim serial1 As Serial
My codes are of no errors before. But after I added the lines that you want us to add, the error message I get is: "Module:s2_br not found". How come?
AddReceiverText(svc_bt_disconnect, <intent-filter> <action android:name="android.bluetooth.device.action.ACL_DISCONNECTED"/></intent-filter>)
I have fix this. I thought I have to code directly, but instead, I should use Service module in Project menu. This code:What is the service name? If is is not s2 then you need to update the manifest text.
I have fix this. I thought I have to code directly, but instead, I should use Service module in Project menu. This code:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim BT_Service_connected As Boolean
End Sub
Sub Service_Create
BT_Service_connected = False
End Sub
Sub Service_Start (StartingIntent AsIntent)
If StartingIntent.Action = "android.bluetooth.device.action.ACL_CONNECTED" Then
Log("BT_Connect")
BT_Service_connected = True
' THE STATEMENT BELOW IS NOT EXECUTING IN MY CASE... !!
Else If StartingIntent.Action = "android.bluetooth.device.action.ACL_DISCONNECTED"Then
Log("BT_Disconnect")
BT_Service_connected = False
CallSubDelayed(Main, "BT_Disconnect")
End If
Log(StartingIntent)
Log(StartingIntent.ExtrasToString)
End Sub
This android.bluetooth.device.action.ACL_DISCONNECTED might not be the way to determine if the bluetooth is disconnected. It fails to detect if it is disconnected. But as connected, it can detect by android.bluetooth.device.action.ACL_CONNECTED. Any suggestions?
AddReceiverText(svc_bt_disconnect, <intent-filter> <action android:name="android.bluetooth.device.action.ACL_DISCONNECTED"/></intent-filter>)
AddReceiverText(svc_bt_connected, <intent-filter> <action android:name="android.bluetooth.device.action.ACL_CONNECTED"/></intent-filter>)
Then I have to create another service for svc_bt_disconnect this time I think. Because I only have a service for s2, which is service connected.you are not currently listening for the disconnect.
This is what I use for handling the same :
B4X:AddReceiverText(svc_bt_disconnect, <intent-filter> <action android:name="android.bluetooth.device.action.ACL_DISCONNECTED"/></intent-filter>) AddReceiverText(svc_bt_connected, <intent-filter> <action android:name="android.bluetooth.device.action.ACL_CONNECTED"/></intent-filter>)
Regards
John.
YepThen I have to create another service for svc_bt_disconnect this time I think. Because I only have a service for s2, which is service connected.
It did work out. But when I turned off the hardware that contains the bluetooth, after I have successfully connected via bluetooth, it says that it is still connected. How come? That's my latest post. That's my latest problem. Hope you can help me with this:Roy this this work out for you ?
It does not matter. Always create a new thread for your issues. Posting to old threads is a mistakewas the nearest I could find for my current problem