Android Question JobDone in OKHttp issue

tigrot

Well-Known Member
Licensed User
Longtime User
Hi Everybody,
If in JOBDONE sub I put the next code:

B4X:
 If job.Success=False Then
       job.Release
End If

in case of success=False I get an error "File missing".
I have seen that the "Release" sub deletes a temporary file.
In the examples the release is issued in any case, both successful or not.
In my opinion if no answer comes from the server the temp file is never created.
Am I wrong?

regards
Mauro
 

DonManfred

Expert
Licensed User
Longtime User
Job.Release should be done at the end of the event sub.
In BOTH situations... Success true/false
 
Upvote 0

tigrot

Well-Known Member
Licensed User
Longtime User
I have probably found the issue: I was connecting www.google.it
B4X:
Dim sito As String= "http://www.google.it"
If httpx.IsInitialized=False Then httpx.Initialize("httpx",Me)
httpx.Download(sito)

Crashes on Job.GetString with no file....
Although job.success is true.
In my opinion the download of the page is not finished when jobdone event is issued.

Mauro
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Dim sito As String= "http://www.google.it"
If httpx.IsInitialized=False Then httpx.Initialize("httpx",Me)
httpx.Download(sito)
Looks like you are dimming it just ONCE and not for each download..

try
B4X:
Dim sito As String= "http://www.google.it"
dim httpx as httpjob ' Use a DIM for EACH Job you want to execute
httpx.Initialize("httpx",Me)
httpx.Download(sito)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
In my opinion the download of the page is not finished when jobdone event is issued.
i cannot agree.
When i get a job.success then the page i loaded is finished loading. in case of google i have the html-code in job.getstring
 
Upvote 0

tigrot

Well-Known Member
Licensed User
Longtime User
I get the error in GetString()(the file containing data from internet server is missing). What's the need for isInitialized call if you need to initialize every time, gothic question....?
Thank you Don(the kindest IT man around!).
I took away the code, since it was only a test to see if Internet was up.
Best regards and have an happy week end!

Mauro
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
What's the need for isInitialized call if you need to initialize every time, gothic question....?
The need is not the second (3rd, 4th...) initialisation.
The need is the creating of a new instance (DIM) of httpjob (this includes the initialisation though)
 
Upvote 0
Top