Is it possible to get a notification when any location provider is enabled/disabled and ascertain what action occurred?

前端 未结 4 2284
挽巷
挽巷 2021-02-20 18:32

I wish to receive a notification when the user enables or disables either Network or GPS locations, and importantly I wish to know which one they have changed and how. I have a

4条回答
  •  误落风尘
    2021-02-20 19:28

    On the Receiver you could simply check which providers are enabled:

    LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE)
    List providers = lm.getProviders(true);
    

    In this way you obtain all the enable providers.

提交回复
热议问题