Hey guys,
Im coming from iOS developing in XCode...
Now I would like to write my first Android App and found this realy nice Software...
But I got an important question, because I got a little problem.
My code goes like this:
In short words, Im receiving numbers and messages from my webserver (CSV "B" and "S" seperator), and I would like to send a sms to each number/message pair.
If I take the output to a listview, everything is fine. If I take the Output to my PhoneSMS (Phone1) object, it creates the following error:
"NetworkOnMainThreadException"
I gues it appears because I tried to send a sms from a background task.
But how do I call a Main Task with B4A?
I know it in XCode, its [self performSelectorOnMainThread:...]; but how do I do it in Basic4Android?
I would appreciate yours for helping me out of this problem.
Thank you in advance!!
If Im getting better in this language, I will come back and help other users with their problems too!!
regards
Dennis:sign0013::sign0104:
Im coming from iOS developing in XCode...
Now I would like to write my first Android App and found this realy nice Software...
But I got an important question, because I got a little problem.
My code goes like this:
B4X:
Sub HTTPClient1_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Response.GetAsynchronously("Response", File.OpenOutput(File.DirInternalCache, "temp.txt", False), True, TaskId)
End Sub
Sub Response_StreamFinish (Success As Boolean, TaskId As Int)
If Success Then
Dim TR As TextReader
TR.Initialize(File.OpenInput(File.DirInternalCache, "temp.txt"))
Result = TR.ReadAll
Dim components() As String
components = Regex.Split("B", Result)
If Result.Length <> 0 Then
Dim i As Int
For i = 0 To components.Length -1
Dim parts() As String
parts = Regex.Split("S", components(i))
Phone1.Send(parts(0),parts(1))
Next
End If
If HTTPClient1.Execute(HTTPRequest1, 1) = False Then Return
Label1.Text = "Weiterleitung AKTIV!"
End If
End Sub
In short words, Im receiving numbers and messages from my webserver (CSV "B" and "S" seperator), and I would like to send a sms to each number/message pair.
If I take the output to a listview, everything is fine. If I take the Output to my PhoneSMS (Phone1) object, it creates the following error:
"NetworkOnMainThreadException"
I gues it appears because I tried to send a sms from a background task.
But how do I call a Main Task with B4A?
I know it in XCode, its [self performSelectorOnMainThread:...]; but how do I do it in Basic4Android?
I would appreciate yours for helping me out of this problem.
Thank you in advance!!
If Im getting better in this language, I will come back and help other users with their problems too!!
regards
Dennis:sign0013::sign0104: