Android show progress dialog while waiting for location

android, android-location

Solution

There is no need of AsyncTask because Location service already running in different process, Just implement the `LocationListener` and register it on resume method, and in onCreateActivity check if location is null, the show the `ProgressDialog`, and in `onLocationChanged()` set the location and close the `ProgressDialog`

Problem

I'm developing location based app using this example: http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/ But when I turn on phone, the location isn't available right on that moment. So I would like to show progress dialog while waiting for the location. Wanna do this in the background using AsyncTask. Can you give any ideas how and where to do that?

Original source