Android: detect when GPS is turned on/off (or when no app is using it anymore)

前端 未结 4 1479
太阳男子
太阳男子 2021-02-13 02:24

I\'m on Android 2.3.7 and I\'m trying to write a BroadcastReceiver that will get called when the user turns GPS on/off (ie: by tapping on the \"use GPS satellites\" in the optio

4条回答
  •  别那么骄傲
    2021-02-13 02:55

    Use a LocationListener and override OnStatusChanged.

    You can attach your listener using the requestLocationUpdates(String, long, float, LocationListener) method on your LocationManager instance.

提交回复
热议问题