Ever since setting my target SDK version higher in order to fix another issue, my app has suddenly been plagued with these dreaded Network on Main Thread exceptions. I spent all day yesterday changing code to avoid anything like this:
Just so I understand, it is only the act of calling Result = Response.GetString("UTF8") as shown above that can cause this, correct?
In other words, it is still okay to use HttpClient for sending simple requests so long as we don't try getting the result directly from the response, right? As with HttpUtils (1), I do still use it but it never calls that but rather it uses:
There are a few instances in my app where it just makes more sense to use the simple HttpClient and even the original HttpUtils. But after spending an entire day messing with this, I want to be sure I am actually fixing the problem. Unfortunately I can't get it to repeat very easily on my Galaxy S3 (Jelly Bean) even though I see reports in my console claiming it happens all the time to others.
B4X:
Sub HttpClient1_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Result = Response.GetString("UTF8")
End Sub
Just so I understand, it is only the act of calling Result = Response.GetString("UTF8") as shown above that can cause this, correct?
In other words, it is still okay to use HttpClient for sending simple requests so long as we don't try getting the result directly from the response, right? As with HttpUtils (1), I do still use it but it never calls that but rather it uses:
B4X:
Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), True, TaskId)
There are a few instances in my app where it just makes more sense to use the simple HttpClient and even the original HttpUtils. But after spending an entire day messing with this, I want to be sure I am actually fixing the problem. Unfortunately I can't get it to repeat very easily on my Galaxy S3 (Jelly Bean) even though I see reports in my console claiming it happens all the time to others.