locationclient.getlastlocation() always returns null on emulator

前端 未结 2 2063
半阙折子戏
半阙折子戏 2021-01-20 04:45

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 fi

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-20 05:20

    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.

提交回复
热议问题