Android Location listener in Service does not work until I reactivate WiFi/mobile network

后端 未结 4 937
我寻月下人不归
我寻月下人不归 2020-12-01 20:29

My location listener works normally, collects data without any problem. But sometimes it doesn\'t collect any data. I have to turn off and restart my location provider at th

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-01 21:08

    Using the network provider requires internet connection to work. It collects some information from the cell and wifi hotspots. It then queries a backend server which looks up its database and gives an approximate location. The device can prefetch some location info so you don't need constant internet connection but when the device moves out of the prefetch location, it will need internet connection again.

    This might be your problem that you loose internet connection sometime (wifi going to sleep) and restarting the provider gets it to reconnect to the internet again. Again this is at best a guess on my part :)

提交回复
热议问题