Location service onProviderEnabled never called

三世轮回 提交于 2019-12-01 12:53:27
Diederik

In your LocationService.onCreate() method your code checks if the GPS provider is disabled.

if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){...}

But you only start the subscription if it is already enabled. Note that your listener is then never registered with the LocationManager and will not receive any updates of location providers being disabled or enabled. Rather change your onCreate() method to always call

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5 * 60 * 1000, 100, this);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!