An AsyncTask does what it calls - the doInBackground(...) method runs asynchronously in a separate thread while the code in onCreate(...) continues to work.
In your code here ...
mat.execute(query); if (overlayList.size() > 0){ tv1.setText("List is OK!"); }
... the if condition if checked immediately after calling mat.execute(query) . In other words, your AsyncTask not able to execute its doInBackground(...) .
Move this code ...
if (overlayList.size() > 0){ tv1.setText("List is OK!"); }
... to the onPostExecute(...) method of your AsyncTask .
EDITING. As pointed out in the comments below, calling the get() AsyncTask blocks the main thread and waits for the result to return. This effectively makes the use of AsyncTask synchronous, in which case it makes no sense to use AsyncTask .
The only reason I can use the get() method will be from a thread other than the main (UI) thread, although I cannot think of many reasons for this.
source share