Search code examples
androidlocation-client

locationclient.getlastlocation() always returns null on emulator


I am new into Android world. I was just referring this tutorial from Google: http://developer.android.com/training/location/retrieve-current.html

Program compiles fine and launches application on emulator, but when I try to find mLocationClient.getLastLocation() it returns null, ALWAYS

I searched for almost a day and ahve already tried sending parameter from DDMS, telnet, switching google MAPs but still no success.

Please help me out.


Solution

  • What eventually worked for me was setting a location (I use Genymotion, so the "GPS widget" in the upper right corner), then starting Google Maps, and then running my app.

    My guess is that my app wasn't actually setting the current location (which I thought connecting my locationClient would do automatically) - Google Maps checks and sets the location, so getLastLocation actually has something to return.