[英]Does an iOS app use battery when in the background or when the device is locked?
I am working on an iOS project where the gyro and accelerometer is always on, has animations running as well as a timer. 我正在做一个iOS项目,其中的陀螺仪和加速度计一直处于打开状态,并运行动画和计时器。
What actually happens to the app on iOS 7 - iOS 10 when switching apps and the app is relegated to the background or when the device is locked -- does the gyro and accelerometer, running animations and timers automatically pause and turn off? 当切换应用程序且该应用程序降级为后台或锁定设备时,iOS 7-iOS 10上的应用程序实际发生了什么?陀螺仪和加速计,运行动画和计时器是否会自动暂停并关闭?
Should I expect when an app is relegated to the background or when the device is locked, the app stops drawing battery? 我应该期望当某个应用降级为后台或锁定设备时,该应用停止消耗电池电量吗?
Or should I manually pause or turn off the gyro and accelerometer, running animations and timers when applicationDidEnterBackground
is triggered and then recommence everything when applicationDidEnterForeground
is triggered? 还是应该在触发
applicationDidEnterBackground
时手动暂停或关闭陀螺仪和加速计,运行动画和计时器,然后在触发applicationDidEnterForeground
时重新开始一切操作?
Your app will stop, and without enabled specific background mode like location updates or Background Fetching it won't return to "run" until it will be in the foreground 您的应用将停止运行,并且在未启用特定的背景模式(例如位置更新或后台获取)的情况下,应用将停止运行,直到它处于前台
The NSTimes will stop also. NSTimes也将停止。 I think it's better practice to update the state in the applicationDidEnterBackground and applicationDidEnterForeground
我认为最好在applicationDidEnterBackground和applicationDidEnterForeground中更新状态
Check Apple Documentation to know about background execution. 查看Apple文档以了解后台执行。
By default, when your app goes to background state then it's not performing any task. 默认情况下,当您的应用进入后台状态时,它不会执行任何任务。
You have to made setup for continue execution in background mode. 您必须进行设置才能在后台模式下继续执行。 And that have
limitations
also like you can not perform everything or anything that you want. 这也有
limitations
例如您无法执行所有操作或所需的任何操作。 You have limitations like, finite length task,location update,background music play, downloading, voip
etc..! 你有限制,例如,
finite length task,location update,background music play, downloading, voip
等。 You can know more from above link. 您可以从上面的链接中了解更多信息。
So, if you have configured anything that's capable to works continue in background, then your app will consumes battery in background otherwise not. 因此,如果您配置了所有能够正常工作的内容,则在后台继续运行,那么您的应用程序将在后台消耗电池电量,否则不会消耗电池电量。
Apple allows only some kind of tasks in background, and one major reason is long battery life !!!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.