使用 GPS 和后台应用程序 ios/android 时的电池寿命 [英] Battery life if using GPS and background app ios/android

查看:26
本文介绍了使用 GPS 和后台应用程序 ios/android 时的电池寿命的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人创建了一个在后台启动并利用 GPS 每隔一分钟左右收集当前纬度和经度的应用程序?如果有,请提供您的电池时间?例如,您的手机可以使用多长时间,直到通过标准手机程序运行该后台应用程序而完全耗尽.

I was wondering if anyone has created an app that starts in the background and utilizes the GPS to gather the current Lat and Long every minute or so? If you have, would you please provide your battery times? As in, how long does your phone last until its all out of juice from just running that background app with standard cell phone programs.

我想看看是否值得花时间为自己创建一个应用程序,但如果我工作了 8 个小时并且在那段时间没有办法为我的手机充电,那么我不想回家它关闭了我,因为我的应用程序我会在我家创建作品.我需要应用程序才能工作,因为它会看到我何时在我家的范围内(通过 GPS),然后从我的手机向我家中的服务器发送命令.所以这就是为什么它需要能够在后台每 1 分钟左右进行一次检查.

I'm trying to see if it would be worth the time to create an app for myself but if i work for 8 hours and dont have a way of charging my phone during that time then i dont want to be going home and it shut down on me since my app i would create works at my house. I need the app to work since it will see when i am in range of my home (from the GPS) and then send commands to my server at the house from my phone. So thats why it would need to be able to stay in the background doing a check every 1 minute or so.

或者只在每天下午 5 点之后打开 GPS(这在 iOS 和 Android 上可行吗?),以便最大限度地减少电池负载?!?

Or only turn on the GPS (Is this doable with iOS &or Android?) whenever its after 5pm each day so that it will minimize the load on the battery?!?

任何帮助或建议都会很棒!谢谢!

Any help or suggestions would be great! Thanks!

推荐答案

看起来我们在处理相同的需求.我的代码定期将 GPS 位置发送到服务器(比如 1 分钟、5 分钟、15 分钟......根据用户要求)直到现在我的代码就像它不断打开 GPS 所以电池寿命只有 3-4 个小时小时(设备/手机充满电时).

It looks like we worked on same requirement. My code sends GPS location to server on regular interval ( say 1 min, 5 min, 15 min... as per user requirement ) untill now my code was like it constantly open the GPS so battery life was very few hours like 3-4 hours ( when device/phone is full charged ).

Stack Overflow 上搜索后,我来到了这个答案.现在为了解决电池问题,我再次重新设计应用程序,使 GPS 在应用程序要上传数据时启动并在 30 秒内停止.

After searching on Stack Overflow i come to this answer. Now to solve battery issue i again re-design the application in such a way that GPS start when application is going to upload the data and stops in 30 seconds.

此外,我将代码从 TimerTask 类更改为 AlarmManger 类,因此它占用的内存要少得多.

Also I change code from TimerTask Class to AlarmManger class so it users much lesser memory.

在这些更改之后,我的应用程序以 1 分钟的间隔运行 10 小时(当手机充满电时)等等.

After these changes my application works 10 hours for 1 min interval ( when phone is full charge ) and so on.

通常电池寿命为 20 小时,并且没有设置可以延长该时间段的间隔,所以我得到了 2 分钟的最佳水平.

Normally battery life is 20 hours, and no interval is set like that it can extends that period, so i got optimum level like 2 minutes.

或者只打开 GPS(这在 iOS 和 Android 上可行吗?)每天下午 5 点以后,这样可以最大程度地减少负载电池?!?

Or only turn on the GPS (Is this doable with iOS &or Android?) whenever its after 5pm each day so that it will minimize the load on the battery?!?

我建议您查看AlarmManager 类的示例.这将是您的最佳解决方案.您的应用程序将非常轻量级.

I suggest you to look AlarmManager class's example. It would be the best solution for you. your application will be very light weighted.

这篇关于使用 GPS 和后台应用程序 ios/android 时的电池寿命的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆