Broadcast receiver for GPS state?

元气小坏坏 提交于 2019-12-20 03:17:27

问题


Is there a way to be notified when the GPS is switched on/off?

I noticed that when the device is switched off an then on again, getLastKnownLocation(provider) is null. So I want to save the location when the GPS is switched off to a database.


回答1:


Register a BroadcastReceiver to listen for the LocationManager's PROVIDERS_CHANGED_ACTION Intent. This will be broadcast when the GPS provider (and other providers) is enabled / disabled.



来源:https://stackoverflow.com/questions/11446428/broadcast-receiver-for-gps-state

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