From my previous question
I was getting NullPointor exception. So i have done some changes in my code and now progress bar is showing up but getting the below error
This is exactly why it's valuable to start understanding some basics around threading instead of just saying "AsyncTask" for everything that seems remotely threading-related in Android. Multi-threading can be tricky and you have to think things through.
I suspect this is what's happening: You have an AsyncTask which among other things gets the location... asynchronously. That means you start on the main thread, you execute doInBackground in another thread implicitly (the AsyncTask's thread), then you call off to whatever thread is doing your location acquisition. Then your AsyncTask thread continues on, finishing off all that JSON-related work in doInBackground, probably finishing. The AsyncTask thread likely finishes. Then you are getting your location lock, and the listener that you provided is called back, except that now the AsyncTask has already finished, and its thread is no longer valid.
Just based on a look at your code I suspect that you want to make that Google Maps API call after you get your location, right? If so, call your "get location" code synchronously. In the callback to that, you can put the code to kick off your AsyncTask which now only does the Google Maps API call and processing.