locationManager.getLastKnownLocation() return null

后端 未结 5 1222
天命终不由人
天命终不由人 2020-12-16 13:32

i dont understand why locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); return the location null. I gave all permission but its reutning

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-16 13:50

    Accoding to the documentation, it returns null, if the device is not aware of the last known location. Probably the GPS can not locate you. It takes about a minute or more, anyway. So try to go outside, under the clear sky, away from tall buildings, and wait until GPS can locate you.

提交回复
热议问题