开发者

Android service location code?

I've been looking everywhere for an example of code that is a Service that update a web server on the users location. this is made almos开发者_运维百科t impossible because of the use of the word 'service' as it is used in the context of location service, for example 'googles location service'. please can anyone point me in the direction of an example where a SERVICE gets the location and does something with it. I can send it to a web service so I'm not asking for that but I just want to know if there is a way of every certain amount of time and distance a service will update the web server?


Look at Android docs about obtaining user location.

You will have to make several decisions:

  1. How accurate do you need your updates to be?
  2. How often do you need them?

This greatly affects device's power consumption. Personally I loathe the apps that prevent full sleep and have GPS constantly turned on - this drains the battery in a couple of hours.

I highly recommend you look at this blog post: A Deep Dive Into Location. There is a link to a great example app.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜