Android Question OkHTTP not executing? (Answered)

Bryanne Vega

Member
Licensed User
Longtime User
I've tried using the examples on the forum, but for some reason, I initialize, then execute an okhttp get, but nothing actually happens, nor de success or error show. Any ideas?

B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("Home")
   okClient.Initialize("getCategories")
   okClient.Execute(Session.requestAllCategories,1000)
End Sub


Sub okClient_ResponseSuccess (Response As OkHttpResponse, TaskId As Int)
   Dim out As OutputStream
   out.InitializeToBytesArray(0)
   Log(out)
   Response.GetAsynchronously("res", out, False, TaskId)
End Sub

Sub res_StreamFinish (Success As Boolean, TaskId As Int)
   Log($" ${Success}"$)
   Log(out)
   If Success Then Log(BytesToString(out.ToBytesArray, 0, out.ToBytesArray.Length, "utf8"))
End Sub


Sub okClient_ResponseError (Response As OkHttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
   Log($"Error: ${Response.ErrorResponse}, ${Reason}, ${StatusCode}"$)
   If Response <> Null Then Response.Release
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…