Issue
I get a network response in my android application with this listener:
void getResponse(String id, Response.Listener<NetworkResponse> listener);
in the fragment I am receiving this response and doing some bigger parsing action:
getResponse(id, response -> {
someBigParsingAction(response);
});
So my first question is this still asynchronous? I would say no, because I can't monitor some usage on other threads except the main thread. On which thread is this running? And would it freeze my UI?
To add a second example:
new AsyncTask<Void, Void, Boolean>() {
protected Boolean doInBackground(Void... params) {
return null;
}
protected void onPostExecute(Boolean result) {
someBigParsingAction(loadDownloadedData());
}
private void doOneThing() {}
}.execute();
Thank you smoo
Solution
You should read docs about AsyncTask. The only callback which running in WorkerThread is doInBackground. onPreExecute and onPostExecute running in UI thread. So the answer is no, your code is synchronous and it will block UI thread.
Answered By - Anton Kazakov
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.