2

What happens if an ActivityA makes a Volley request (ASAIK, Volley request runs not on the UI Thread), and let's say that the volley request ask for a lot of data. Volley request has a callback method named onResponse, that contains the JSON Objected returned as a response, and this method runs on the UI-Thread. inside this method we will parse the object, make ProgressBar visibilty to GONE and add the items into ReyclerView that is part of the ActivityA. While the request is in progress, we are showing a circled progress bar. Now (Before the response was returned) user decided to "leave" temporarily the application (so onPause runs). What will happen when the result from the server arrive? Does trying to update the UI will cause an Exception, or the UI Thread and the ActivityA still alive? If they are alive so what will happen when the user will return to application? Is he still see the progressBar, or the RecycelrView filled with the items from the JSONResponse?

Eitanos30
  • 1,331
  • 11
  • 19
  • Until your Activity is still alive in the memory, your code will update the UI and if the user returns to your Activity, the user will see the updated UI. – just Oct 30 '20 at 09:48
  • @just, Does it mean that all the data is being updated by the main UI Thread, and the screen is being render, only when the user return to application/Activity? – Eitanos30 Oct 30 '20 at 15:30
  • As far as I know yes. But lets try it out ;) – just Oct 31 '20 at 23:17
  • @just . Ok :) Thanks – Eitanos30 Nov 02 '20 at 10:14

0 Answers0