So, in my program i have a TabActivity which contains two tabs, one tab is a ListView and another is a MapActivity that gets started via an Intent. What i want my app to do is send a query with phones location and the name of a product and reveice a list of nearest shops that have this product, then show those shops in the map tab and show the list of them in another tab. The app starts listening for location when TabActivity is started and the communication with the server (in AsyncTask) starts as soon as location is obtained.
The problem is that when TabActivity starts, it also starts the MapActivity because it is in its first tab, and the MapActivity starts to try to add overlays on the map but there is no data yet for these overlays, because the AsyncTask in TabActivity hasnt finished getting data from the server yet, which crashes the program.
I need my app to show an empty google map when TabActivity is first opened and wait for the data to be obtained from server and then add overlays to the map to mark the shops on it. Can anyone show me how can I achieve this? I guess i should remove the Overlay making part of code from onCreate in MapActivity and put it somewhere else but i dont know where.