If Job.JobName="songrafik" Then
If Job.Success = True Then
Log(Job.GetString)
Dim parser As JSONParser
parser.Initialize(Job.GetString)
As I can understand from the percentage of error ( it is around %5 of all users ) most of the time there is no problem , but I want to fix this. If the job is success , I must have get the json also because it is impossible to get a blank response from the server. This error happens when the received response is not json so to fix this ,
Can I use for example try catch for the above code and if stg is catched repeat this job ?
Yes , I was thinking that , if i check if the job.getstring.length is less then 10 for example , and if it is less than 10 repeat the job request , I would fix the problem, it is better than try catch ..
With Wait For, that could be easier implemented than using JobDone.
B4X:
'
Do While retry = True
Dim j As HttpJob
j.Initialize("", Me)
j.Download("https://www.google.com")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
Dim parser As JSONParser
Try
parser.Initialize(j.GetString)
retry = False
Catch
Log(LastException)
End Try
End If
j.Release
Loop
Note: Just noticed that this will repeat constantly if j.Success is False. That may or not may not be the intended purpose and the code may need to be adjusted. Plus, you don't have to use try/catch (should have read follow up posts better), but then this can be adapted to whatever is used to determine if the returned value (j.GetString) is acceptable.