The code below is in a Service module. The service is always running whilst the app is open. The App occasionally fails when the user is not touching it but the Main Activity screen is open and visible and the service running in the background. It only fails when the Bluetooth connection (in the Service Module) is active, and even then only occasionally, perhaps once or twice per hour.
Could it be due to me calling other procedures in a Code Module (called Subs)? Or when I reference a List in the Main activity?
The code in the Subs module (Store_Response) writes to a SQL database. Could this be the cause?
I hope this next bit works... Not inserted code in a post before...
Could it be due to me calling other procedures in a Code Module (called Subs)? Or when I reference a List in the Main activity?
The code in the Subs module (Store_Response) writes to a SQL database. Could this be the cause?
I hope this next bit works... Not inserted code in a post before...
B4X:
Sub AStream_NewData (Buffer() As Byte)
Dim myResponse As String
myResponse = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
Log("Received: " & myResponse & " at " & DateTime.now)
Dim myID As Int
myID = Subs.Store_Response(myResponse)
Dim PausedIndex As Int
PausedIndex = Main.PausedList.IndexOf(myID)
If Main.PausedList.Size > 0 Then
If PausedIndex > -1 Then Main.PausedList.RemoveAt(PausedIndex)
Else
Log("Response [" & myResponse & "] could not be associated with a command being waited on")
End If
End Sub