广播接收器,GPS状态?接收器、状态、GPS

由网友(主攻撩汉)分享简介:有没有办法当GPS开启被通知开/关?Is there a way to be notified when the GPS is switched on/off?我注意到,当设备关闭了再打开,getLastKnownLocation(供应商)为空。所以,我要救当GPS关闭到数据库的位置。I noticed that...

有没有办法当GPS开启被通知开/关?

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

我注意到,当设备关闭了再打开,getLastKnownLocation(供应商)为空。所以,我要救当GPS关闭到数据库的位置。

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.

推荐答案

注册一个BroadcastReceiver来监听LocationManager的 PROVIDERS_CHANGED_ACTION 意图。当GPS提供商(和其他供应商)启用/禁用这将播出。

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.

阅读全文

相关推荐

最新文章