I have a button that calls requestQueue.add method of the Volley library. Inside the onResponse method i call:
popupBox.display(getString(R.string.successfulRegistration), false, true);
Display method, displays a popup window thus must be called inside UI thread.
I put a break point at the beginning of the onResponse
method.
Immediately after clicking on the button, switch to another app and send my app to the background.
IDE stops on the break point and I get my answer from the server but my app still is in the background and there is no exception error.
After about a minute, I bring my app to the foreground. After that, the message window pops up.
Is that mean, I don't need to check if I can do something related to UI thread inside the onResponse
method because volley handles it?
onResponse
andonErrorResponse
are called on main thread by default unless you are trying to call them from some other tread. Volley makes the Api call on a non ui thread (non UI blocking). Volley doesn't take care of your life cycle. So, if you make a api call in an activity and close that activity, the callback are received. So, you should check whether the activity is in foreground or not.