LocationManager don't get the right results

后端 未结 2 1425
醉梦人生
醉梦人生 2020-12-22 08:28

I am using LocationManager to convert from lat,longi to get the city name, but I am getting wrong results, I think there is something wrong in this code here:



        
2条回答
  •  旧巷少年郎
    2020-12-22 08:53

    Did you try turning on your gps to get a location fix? According to the docs, this method returns:

    the last known location for the provider, or null

    Make sure you had a location fix on your phone before for this to work. Also, you might want to consider this post which covers a good strategy to get the user location when there is one available or request a new one otherwise.

    Hope it helps.

提交回复
热议问题