How to? Listen for Location Setting being turned ON (Android App)

后端 未结 3 1450
借酒劲吻你
借酒劲吻你 2021-01-02 02:30

So I\'ve spent the past few weeks working on my Android App and looking into the best way of implementing what I need to do, but still can\'t quite get it right.. Any/all he

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-02 03:15

    LocationListeners's onProvideEnabled() method will work instantly. When you call this remember if you are doing LocationManager.removeUpdates() in between onProviderEnabled() won't work.

    And this is pretty much simple when you are reading locations from Location API's of Android. You don't need the broadcast receivers listening and communication further

    But when you are using FusedLocationProviderClient from google API and if you use LocationListener's onProviderEnabled and onProviderDisabled methods you will be having two services running in parallel, checking for the provider changes. So using BroadcastReceiver is better

提交回复
热议问题