简体   繁体   English

在后台或设备锁定时,iOS应用程序会使用电池吗?

[英]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.

相关问题 当设备被锁定时,什么可以在后台唤醒 iOS 应用程序? - What can wake up an iOS app in the background when the device is locked? 设备锁定时,iOS应用是否处于活动状态? - Is an iOS app active when the device is locked? 当音频在iOS应用中运行时,应在设备锁定但应用未置于后台时继续播放 - When audio runs in iOS app,it should continue playing when device is locked but not app put in background Swift - 检测应用程序何时发送到后台但不是设备被锁定时 - Swift - Detecting when app is sent to background but not when device is locked 设备锁定时的文件安全性以及iOS7中的后台提取 - File security when device is locked and background fetch in iOS7 当应用程序处于后台或设备锁定时,Airplay 停止播放视频流 - Airplay stop playing video streaming when app is in background or device locked 当应用程序在后台且设备被锁定时处理推送通知 - Handling push notification when app is in background and device is locked 使用密码锁定屏幕时,IOS应用程序无法访问后台文件 - IOS app unable to access files in background when screen locked with passcode iOS:如何在应用程序处于后台时检查屏幕是否已锁定 - iOS: How to check if screen is locked when app is in background 当应用程序进入后台时,iOS Phonegap sqlite数据库被锁定 - iOS Phonegap sqlite database getting locked when app go to background
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM