Working on some check-in functionality for an application, and trying to figure out the cleanest way to handle the lastKnowLocation being null. Currently, I attach a location listener and then fire off an asynctask which publishes an indeterminate progressdialog, alerting the user that I am searching for a the gps to gather their location; the doInBackground method is essentially just a busy wait loop, waiting on the location to not be null. As a disclaimer, I feel like this current implementation is bit “jenky” from a code standpoint, but provides the expected user experience. However, I am wondering if anybody could provide insight as to what would be a better way to handle this fairly common scenario.
Thanks
I’m not for the progress dialog because if the GPS takes forever then so will your app, killing the UX. In the activity with the dialog why not have a global locationFound boolean, a lastLongitude and lastLatitude. The advantage of that being if the you use the GPS returned to open another activity and the user navigates backwards you can even implement a “See previous results” or whatever the terminology is for your app. Here’s how i implemented a GPS location wait in an activity for a small app i did a while ago, excluding the code that doesn’t matter for your question