How to continuously track the location of an Android mobile phone?

后端 未结 1 1942
猫巷女王i
猫巷女王i 2020-12-04 23:10

I need to write an app, which every 5 minutes determines the current location of the mobile phone (using all free, available location providers) and sends it to a server.

相关标签:
1条回答
  • 2020-12-04 23:19

    Your code is probably correct, but location providers are not running when your phone is sleeping. You may need to acquire a wakelock (if you don't care about power draw), or use AlarmManager and schedule your application to wake up and check location periodically (you still need to have active wakelock while you are waiting for an update, either acquired by AlamManager, or your own).

    0 讨论(0)
提交回复
热议问题