Hi everybody!
I hope that my english is good enough to explain my problem.
I have an application which sends data to a socket-server within a service.
I´m using an AsyncStream-object to send the data.
Right now I´m using only the mobile network. No WiFi.
Now my problem:
Normaly the connect-function works fine. But when there is a bad mobile network coverage (the ConnectivityChanged-event in my PhoneEvents-object gives still CONNECTED) the connect-function freezes the whole app.
After a few seconds an os-message pops up: A service takes time. Try to close. Wait.
I can say "wait" and everything is fine. The app comes up again.
I hope the someone can help me out! :sign0163:
Here are some code-snippets:
By the way: I tried several values as Timeout (5000, 2000 and 0).
I hope that my english is good enough to explain my problem.
I have an application which sends data to a socket-server within a service.
I´m using an AsyncStream-object to send the data.
Right now I´m using only the mobile network. No WiFi.
Now my problem:
Normaly the connect-function works fine. But when there is a bad mobile network coverage (the ConnectivityChanged-event in my PhoneEvents-object gives still CONNECTED) the connect-function freezes the whole app.
After a few seconds an os-message pops up: A service takes time. Try to close. Wait.
I can say "wait" and everything is fine. The app comes up again.
I hope the someone can help me out! :sign0163:
Here are some code-snippets:
B4X:
'Service module
Sub Process_Globals
Dim AStreams As AsyncStreams
Dim Socket1 As Socket
Dim OpeningSocket As Boolean
Dim SocketHost As String
SocketHost = "www.XXXXXXX.XX"
Dim SocketPort As Int
SocketPort = XXXX
End Sub
Sub connectToSocket
If PhoneService.myPhoneIsReady = False Then
Return
End If
OpeningSocket = True
Try
Socket1.Initialize("Socket1")
Socket1.Connect(SocketHost, SocketPort, 0)
Catch
End Try
End Sub
Sub Socket1_Connected (Successful As Boolean)
Try
If Successful Then
AStreams.Initialize(Socket1.InputStream, Socket1.OutputStream, "AStreams")
End If
OpeningSocket = False
Catch
OpeningSocket = False
End Try
End Sub
Sub AStreams_NewData (Buffer() As Byte)
....
End Sub
Sub AStreams_Error
...
End Sub
By the way: I tried several values as Timeout (5000, 2000 and 0).