Android : Difference between LocationManager.addProximityAlert() & LocationClient.addGeofences()

隐身守侯 提交于 2019-12-21 20:37:33

问题


Both of these serve as a mechanism to notify once the user enters/exits a given point of interest. What are the pros and cons of each ?


回答1:


Coming from someone who switched over to Google Play Services a while ago, i can give you some experiences:

I have an app, about 2,5 years old, that uses location services extensively. From the outset, of course, we used the LocationManager since that's what was available on the Android platform.

We had a pretty bad experience with Location Services on Android compared to IOS. It was buggy, unreliable, and gave less precise locations than than our IOS app, plus that it drained more battery. It was a drag.

Therefor, when Google unveiled the new API in june this summer, we jumped at it. It is way better. A couple of things:

  1. It is quicker and more reliable.
  2. it is less buggy. As an example, in the old API we could sometimes get an "old" fix with a new timestamp. This never happens anymore. There's more but it would be an even more lengthy post.
  3. It definitely drains less battery. For example, when you had a map view open, the GPS ran all the time, and the GPS icon was visible. This is not the case with the new one. This made users wonder what was going on. This is nolonger as big an issue.

So, when it comes to the location output and work, everything is better. But there are some downsides:

  1. You have to have Google Play Services installed, meaning it wont work on any "non-google-approved" phone models, and in some instances you'll have to tell users they need to install it.

  2. The API itself is more complex IMO, in part due to point 1. In addition to the "regular" callbacks i.e. waiting for location fixes etc. You now have a process that takes part before you can get started where you have to check that playservices is available, and "connect" the locationclient. This is extra code and a bit more complex to grasp. More faulty conditions to take into account in the code too (if you can be bothered...)

  3. Google play services itself requires at least 2.2 so it won't work for older devices than that. We had to tell some clients they had to upgrade...

Hope this helps.



来源:https://stackoverflow.com/questions/20908822/android-difference-between-locationmanager-addproximityalert-locationclien

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