Sub Activity_Create(FirstTime As Boolean)
Dim Job1 As HttpJob
Job1.Initialize("CheckDevice", Me)
Job1.Download2("http://www.xxxx.yyy/register/register.php", _
Array As String("Action", "CheckRegister", "Imei", imei, "Mail", RegMail.Text))
End Sub
Sub JobDone (Job As HttpJob)
...
End Sub
This doesn't work for the first time (with the message above):
B4X:
Sub Activity_Create(FirstTime As Boolean)
CheckDev
End Sub
Sub JobDone (Job As HttpJob)
...
End Sub
Sub CheckDev
Dim Job1 As HttpJob
Job1.Initialize("CheckDevice", Me)
Job1.Download2("http://www.xxxx.yyy/register/register.php", _
Array As String("Action", "CheckRegister", "Imei", imei, "Mail", RegMail.Text))
End Sub
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 Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Button1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
'just a button to trigger
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub JobDone(Job As HttpJob)
ProgressDialogHide
If Job.Success Then
Dim res As String
res = Job.GetString
Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
Else
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Sub checkd
Dim Job1 As HttpJob
Job1.Initialize("CheckDevice", Me)
Job1.Download2("http://www.b4x.com/print.php", _
Array As String("first key", "first value :)", "second key", "value 2"))
End Sub
Sub Button1_Click
checkd
End Sub
By the way: I wonder why every example about httputils(2) is placed in Activity_Create(FirstTime AsBoolean) ONLY. Is there a special reason for it?
This code (I call www.b4x.com/print.php copied from Erels httputils2 example) only works from the 2nd call. At call #1 the message above occurs and I don't have a clue.
There is a Layout with a simple button to trigger checkd.
@Erel : When I test an app using httputils2 and set some breakpoints arround initializing the httpjob then the behaviour occurs (doesn't come back to job done & message is logged but works after the 1+n'th try). Seems that this kind of process doesn't want any interruption.
Without breakpoints between, it works without any problems.
I took your php script to demnonstrate. Setting breakpoints outside of this - let's say "little time corridor between Job.Download2 and JobDone" - is ok.