A misunderstanding of IOS multitasking [multitasking]

Source: Internet
Author: User

Reprint Address: http://blog.csdn.net/kmyhy/article/details/7940704

Today, multitasking is an interesting feature that has been successfully integrated into the device, and one of the things that we use today to fully support multitasking is something that's especially good. This is Apple's iphone.

iOS is a widely used and stunning operating system. After 2010 years, iOS 4 became a multitasking operating system. As we all know, when you open an application and then quit, it will still remain in the background.

Of course, this can lead to battery consumption and you have to manually close them. Actually, it's not about battery consumption at all. Some developers also mention this in their blogs.

Fraser Speirs is a programmer for connected flow, and head of the IT and computer department at Cedar School of Excellence (a teenage school in Scotland, using the ipad for teaching). In his article, he explains the beautiful misunderstanding about iOS multitasking.

The first is about battery consumption: this really needs to be noticed, but the problem is differentiated, and the person who says it doesn't know the real reason.

He further explained: In fact, the iOS multi-taskbar does not contain "All running applications List", it is only "Recently used application List". There is no need for users to manage iOS background tasks on their own.

In addition to some special cases (I will explain), the app that appears in the multiple taskbar is not currently running. When you press the home button, iOS notifies the app to quit. In most cases, it exits, no longer consumes CPU time (including batteries), frees up memory (restores when needed).

He explains: IOS apps have 5 states:

Stop running-The application has been terminated or has not been started.

Inactive-The application is in the foreground but no longer receives events (for example, the user locks the device while the app is active).

The active-app is in the "in use" state.

The background-app is no longer displayed on the screen, but it still executes code.

Suspend-app still resides in memory but no longer executes code.

Here, we do not discuss the activity/inactivity status of the app. The vast majority of the confusion arises when the app goes from the active state to the background, then hangs up, and finally stops running.

When the home button is pressed, the app goes backstage from its active state, and most apps usually turn from backstage to hang in a matter of seconds.

The first technical detail is that the pending app still resides in the device's memory. That's why you can quickly recover them when you return to the app. They do not consume CPU time or battery power.

You will think that if the app resides in memory, you have to find ways to remove them to save memory. If you don't delete them, iOS will also delete them. If the app is in a suspended state, when you open a memory-sensitive app, such as a big game, iOS automatically cleans up the pending apps and turns them off. In this way, they are completely cleaned out of memory, and when you click the app icon again, they reboot.

It's easy to confuse: all of this has no effect on the multitasking bar. Multi-task Cables always display the list of recently used apps, regardless of whether they are in the background, suspend, or stop running state. You should note that the currently active app does not appear in the multiple taskbar.

Background Tasks

When the app is moved to the background, it is usually moved to a suspended state within a few seconds. App can extend this time by declaring a "background task".

For example, some apps need to download larger files. Like my favorite microblogging instacast. When Instacast is active, it starts downloading a new blog. If I click on the Home button, Instacast will take 5 seconds to continue running in the background state and then hang up. This will interrupt the download of the blog, perhaps 5 minutes or more.

iOS allows Instacast to declare a background download task. This will let Instacast still have extra time to run in the background after I press the home key, knowing that the blog download is complete. App can request the background run time is not unlimited, app can only apply for about 10 minutes of background running time, and then by iOS forced to suspend. But you don't need to worry about that.

Unlimited background run time

All apps have 5 seconds of background running time. Some apps can request 10 minutes of extra time. A small number of apps do require unlimited background uptime, and iOS is allowed.

To be exact, in iOS5, there are 5 types of apps that allow unlimited background running time:

1. You can play the audio app in the background. For example, when Instacast is playing a blog.

2. You can track your location in the background of the app. For example, the TomTom navigation system makes voice prompts even when another app is active.

3. Monitor the app that VoIP calls in. When Skype is running in the background, you can still receive Skype calls when you use Skype.

4. Can download new content of the newspaper category app.

5. Background continuously receive updates from external hardware (Exernalaccessory framework).

The top 5 apps automatically become suspended when the task is finished executing. When Instacast stops the blog playback, it hangs. There are also some iOS-brought apps that run in the background, and the most likely to be mail programs.

No matter how long the app runs in the background, they take up memory, CPU time, and battery power. Generally, you will know that you are using a similar app. Developers must declare the background run categories they need, and the App Store will check to see if the claims are abused.

As I said earlier, "there is no need for users to manage iOS background tasks on their own." Of course, it's a different story if the app that runs in the background crashes and doesn't shut down properly. But for iOS users, that's not a lot to see.

Summarize

Let's recap:

When someone tells you that all the apps in the multitasking bar are currently running, they're all memory-consuming or battery--that's not true.

When you press the Home button, the app changes from active to background and quickly turns to a suspended state, where it no longer consumes CPU time and electricity.

An app can request a 10-minute background run time to complete a long task before it becomes a pending state.

When memory is tight, iOS automatically removes the pending app, turning it into a stop state and reclaiming memory.

There are 5 categories of App-audio, GPS, VOIP, newsstand (newspaper columns) and accessory, and some built-in apps (such as mail) can run indefinitely until their task is completed.

Simply put: You don't need to manage iOS background tasks. The system will be automatically processed, and all you need to do is write your audio, GPS, VOIP, newsstand and accessory apps.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.