我正在开发中,我想有地理位置功能的小型Android应用程序。 我想code是一个服务是否正在使用我的应用程序,或没有这给用户的更新的位置。
I am developing a small android application in which I want to have Geolocation functionality. What I want to code is one service which gives the updated location of a user whether they are using my application or not.
我知道,如果我不断地检查用户的位置,它会耗尽设备的电池,所以我想为很好的解决方案。例如,给我更新,每5分钟或10分钟。我看了一下这个问题了很多,但我希望得到一个很好的解决方案。
I know that if I am continuously checking the user's location it will drain the battery of the device, so I want good solution for that. For example, to give me updates every 5 or 10 minutes. I have read about this question a lot but I wanted to get one good solution.
我看了此页面,它的一个很好的解决方案,如果用户使用的是我的应用程序,但如果用户不使用我的应用程序,然后我该怎么办?我该如何解决这个难题?
I read this page and it's a good solution if the user is using my application but if the user not using my application then what should I do? How do I solve this challenge?
pviously我已经开发了这样一种应用$ P $。对于您的要求,您将需要从下面的Android的API。
Previously i have developed such kind of application. with respect to your requirement, you will be require following APIs from Android.
位置(为经纬度信息) AlarmManager (安排一个事件来获取定期与放大器经纬度信息;数据上传到远程服务器) 在HTTP(API来发送经纬度信息到远程服务器) 在Android的服务(将允许在后台运行) 的BroadcastReceiver(更多,如果你婉在设备启动时自动启动应用程序) Location ( for Lat-lon information ) AlarmManager ( to schedule an event to fetch lat-lon details on regular basis & upload data to remote server ) Http ( an API to send lat-lon details to remote server ) Android Service ( will allow to work in background ) BroadcastReceiver ( additional , if you wan to start your application automatically on device boot )