How to disable program exit in IOS 4 and keep it in the background

Source: Internet
Author: User
Tags exit in

You only need to addUiapplicationexitsonsuspend.

Opting out of background execution

If you do not want your application to remain in the background when it is quit, you can explain itly opt out of the background execution model by adding Uiapplicationexitsonsuspend Key to your application's info. plist file and setting its value to yes. when an application opts out, it cycles between the not running, inactive, and active States and never enters the background or susponded states. when the user taps the Home button to quit the application, the applicationwillterminate: method of the application delegate is called and the application has approximately five seconds to clean up and exit before it is terminated and moved back to the not running state.


Opting out of background execution may be preferable for certain types of applications. specifically, if coding for the background may require adding significant complexity to your application, terminating the application may be a simpler solution. also, if your application consumes a large amount of memory, the system might need to terminate your application quickly anyway to make room for other applications. thus, opting to terminate, instead of switch to the background, might yield the same results and save you development time and effort.


Note: explicitly opting out of background execution is necessary only if your application is linked against iPhone SDK 4 and later. applications linked against earlier versions of the SDK do not support Background execution as a rule and therefore do not need to opt out explicitly.

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.