Android Question httputils settings and error messages

JdV

Active Member
Licensed User
Longtime User
Hi

Is it possible to alter the settings for httpjobs (in particular the timeout)? If so, how?

Can the error messages that are reported by the library in the form of toastmessages (such as when a URL cannot be reached) be suppressed or trapped in some other way? If so, how?

Regards

Joe
 

DonManfred

Expert
Licensed User
Longtime User
If so, how?
Comment the line which creates the Toast in your source.

Maybe you need to upload your project or give us more info.

My apps only show toast when using httputils when I created them to show
 
Upvote 0

JdV

Active Member
Licensed User
Longtime User
DonManfred

Thanks for the quick response.

I'm referring to the version of httputils that's included in the IDE, not the code module version - which you're right I could edit to remove the toastmessages.

Joe
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Give me link to the one you are refering to please
But as time of today you should replace your http and httputils with okHTTP and okHTTPUtils2
I´m relatively sure the most uptodate versions do not add any Toasts.

As seen here the Toast is part of the example-code...
B4X:
Sub JobDone (Job As HttpJob)
   Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
   If Job.Success = True Then
      Select Job.JobName
         Case "Job1", "Job2"
            'print the result to the logs
            Log(Job.GetString)
         Case "Job3"
            'show the downloaded image
            Activity.SetBackgroundImage(Job.GetBitmap)
      End Select
   Else
      Log("Error: " & Job.ErrorMessage)
      ToastMessageShow("Error: " & Job.ErrorMessage, True)
   End If
   Job.Release
End Sub
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
in particular the timeout
B4X:
Dim job As HttpJob
job.Initialize("job1", Me)
job.Download("https://abc.com/xyz.asp")
job.GetRequest.Timeout = 60000
Please note to call the GetRequest.Timeout AFTER calling job.Download (or any other similar method)
 
Upvote 0

JdV

Active Member
Licensed User
Longtime User
I have switched to using the okhttp and okhttputils2 libraries and it still produces a toastmessage if there's an error.
 

Attachments

  • TimeoutMsg.png
    TimeoutMsg.png
    4.4 KB · Views: 124
Upvote 0
Top