1 Preface
In the previous section, we introducedProgramExecution status. From the example, we can find that there are clear policies to follow when processing these status changes. This time we will introduce it.
2. Details 2.1 activity-no activity
UseApplicationwillresignactive :/UiapplicationwillresignactivenotificationTo pause the display of the application. Ensure that timely user input is not required at work, because the application does not obtain any user input for a period of time.
2.2 No activity-"background
UseApplicationdidenterbackground :/Uiapplicationdidenterbackgroundnotification releases any resources that do not need to be retained when the application is in the background State (such as cached images or other data that can be easily loaded ), or any resources (such as network connections) that cannot be stored in the background ). This avoids excessive memory usage and reduces the final pause snapshot of the application, thus reducing the overall clear risk of the application from Ram. You can also use this opportunity to save any necessary application data, which will help you find the progress of the last exit at the next restart.
2.3 background-no activity
UseApplicationdidbecomeactive :/Uiapplicationdidbecomeactivenotification resume fromBackground statusSwitchInactive statusAny operations performed. For example, you can re-establish a persistent network connection here.
2.4 no activity-Activity
Use applicationdidbecomeactive :/Uiapplicationdidbecomeactivenotification restores any operations from activity to activity status. This method and notification are used when the application starts completely new, so any operations executed here must also be valid in this context.
Note: during this process, the system does not provide much time to save the changes here, but only provides 5 seconds. If it takes more than 5 seconds, the application will immediately be clear from the memory and enter the not running status!
3 conclusion
The above is all content and I hope it will help you.