Android Question Unable to resolve host using OkHttpUtils2

DawningTruth

Active Member
Licensed User
I am using the following boilerplate code for OkHttpUtils2 with Wait For:
B4X:
Public Sub FetchData

   Dim myJob As HttpJob
 
   myJob.Initialize("", Me)
   myJob.Download("https://www.wikipedia.org/")
   Wait For (myJob) JobDone (myJob As HttpJob)
   If myJob.Success Then
       Log(myJob.GetString)
   Else
       Log("Error: " & myJob.ErrorMessage)
   End If
   myJob.Release
     
End Sub

The only thing out of the ordinary is this Sub is run from a separate class.

I was getting an error with my website, so I tried a couple of others. I keep getting the following error in the logs:

*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
ResponseError. Reason: java.net.UnknownHostException: Unable to resolve host "www.wikipedia.org": No address associated with hostname, Response:
Object context is paused. Ignoring CallSubDelayed: JobDone

On other occasions I just get:

*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
Object context is paused. Ignoring CallSubDelayed: JobDone


Everything should be working. Any suggestions?
 
Last edited:

mare1980k1

Member
Licensed User
Longtime User
Try to put Public Sub FetchData in starter activity. It seems that activity that you are initializing it right now from gets paused, so it causes errors.
Also try to add this in manifest
B4X:
AddPermission(android.permission.INTERNET)
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

DawningTruth

Active Member
Licensed User
Thx for all the help :).

Managed to get it working. Had to break my architectural separation. Basically I moved the Sub from the separate data fetching class to the active Activity and it worked without any code changes.
 
Upvote 0
Top