Service Revamped and Cleaned Where is the Code reentry
:BangHead::BangHead::BangHead:
Specifically HttpUtils Service-- I have given up on the Odd Custom way I was going to implement a Code module to interpret all of the web service calls. But I cant get "focus" back into my application MAIN after the HttpUtilService has done its work and updates a global variable exposed in process globals in my Main. the Flow is ..
Activity Main checks for First time.. If True it loads the login layout::
The Button Click for the login layout is handled in the Main Activity Module
it validates the user input a bit before calling another method
ValidateUser(m_strUzrNm) ::
which calls the HttpUtil stuff ::
HttpUtils.PostString("POST Job1", PostUrlLogin, "p_CartNumber=100&p_Login=" & userName)
The Http Util does its job nicely and the JobDone Sub in the Main Activity Module accompanied by the XmlSax Parser and its Subs again ALL in the Main Activity Module harvest my response from the Web Service beautifully and update the process Global boolean variable
But heres where I'm confused.
If the method ValidateUser actually calls the HttpUtils ----- when the HttpUtils (JobDone & the Parsers) are finished where does the code focus go????
The Service (HttpUtil) calls Service_Destroy and just stops. It never "returns" to the calling Sub to do stuff with the value it has (in this case) harvested from the web service.
Where do I force-in the validation against the returned value and switch activities or invalidate the current and notify the user of their failure...
For example the MessageBox in this method is NEVER invoked ::
:BangHead::BangHead::BangHead:
Specifically HttpUtils Service-- I have given up on the Odd Custom way I was going to implement a Code module to interpret all of the web service calls. But I cant get "focus" back into my application MAIN after the HttpUtilService has done its work and updates a global variable exposed in process globals in my Main. the Flow is ..
Activity Main checks for First time.. If True it loads the login layout::
B4X:
Sub Activity_Create(FirstTime As Boolean)
HttpUtils.CallbackActivity = "Main"
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.CallbackUrlDoneSub = "UrlDone"
If FirstTime Then
Activity.LoadLayout("loginactivity")
Else
If m_boolLoginSuccess = True Then
StartActivity("postMain")
Else
Activity.Invalidate
End If
End If
End Sub
The Button Click for the login layout is handled in the Main Activity Module
it validates the user input a bit before calling another method
ValidateUser(m_strUzrNm) ::
which calls the HttpUtil stuff ::
HttpUtils.PostString("POST Job1", PostUrlLogin, "p_CartNumber=100&p_Login=" & userName)
The Http Util does its job nicely and the JobDone Sub in the Main Activity Module accompanied by the XmlSax Parser and its Subs again ALL in the Main Activity Module harvest my response from the Web Service beautifully and update the process Global boolean variable
B4X:
Sub JobDone (JobPassed As String)
parser.Initialize
Dim InputStream As InputStream
Dim strRetVal As String
Select JobPassed
Case "POST Job1"
'Case "TryLogin"
If HttpUtils.IsSuccess(PostUrlLogin) Then
InputStream = HttpUtils.GetInputStream (PostUrlLogin)
Log(HttpUtils.GetString(PostUrlLogin))
Log(InputStream)
parser.Parse(InputStream, "Parser")
Else
End If
End Select
'Turn off the complete flag so we won't handle it again if the activity is resumed.
HttpUtils.Complete = False
End Sub
But heres where I'm confused.
If the method ValidateUser actually calls the HttpUtils ----- when the HttpUtils (JobDone & the Parsers) are finished where does the code focus go????
The Service (HttpUtil) calls Service_Destroy and just stops. It never "returns" to the calling Sub to do stuff with the value it has (in this case) harvested from the web service.
Where do I force-in the validation against the returned value and switch activities or invalidate the current and notify the user of their failure...
For example the MessageBox in this method is NEVER invoked ::
B4X:
Sub ValidateUser(userName As String)As Boolean
parser.Initialize
' HttpUtils.PostString("POST Job1", PostUrl, "p_CartNumber=45&p_Login=IPTI")
HttpUtils.PostString("POST Job1", PostUrlLogin, "p_CartNumber=100&p_Login=" & userName)
If m_boolLoginSuccess == True Then
Msgbox("Validation Value: " & m_boolLoginSuccess, "")
Else
End If
End Sub
Last edited: