What's the most battery-efficient approach of using LocationClient to periodically get updates?

后端 未结 2 1477
生来不讨喜
生来不讨喜 2021-01-02 16:19

I am thinking about having two separate alarms to gather a user\'s location data every hour, one that goes off every 59 minutes to \"connect\" the client and a second to act

2条回答
  •  温柔的废话
    2021-01-02 17:15

    Do you actually need to track the user?

    If it's just about UI, then use getLastKnownLocation(PASSIVE_PROVIDER) and you should get something semi-accurate assuming they used location services on their phone somewhere else.

    If you need to actually triangulate the user, realize the different providers use different battery. Passive < Network < GPS.

    The more you locate the user, the more battery with GPS taking the most battery and time.

    Start the service by intent one a schedule, 1 hour or whatever, only one service necessary. Only live for a maximum of 1 minute (or less), listen on all Location providers. After the minute or accuracy is good enough, you save the result and shut down the service.

提交回复
热议问题