Hi,
We are
about to learn all different states of an iOS app.
The system
moves your app from state to state in response to actions happening
throughout the system. For example, when the user presses the Home
button, a phone call comes in, or any of several other interruptions
occurs, the currently running apps change state in response.Following
are the app states,
1. Not
running : The app has not been launched or was running but was
terminated by the system.
2. Inactive
: The app is running in the foreground but is currently not
receiving events. (It may be executing other code though.) An app
usually stays in this state only briefly as it transitions to a
different state.
3. Active
: The app is running in the foreground and is receiving events.
This is the normal mode for foreground apps.
4. Background
: The app is in the background and executing code. Most apps
enter this state briefly on their way to being suspended. However, an
app that requests extra execution time may remain in this state for a
period of time. In addition, an app being launched directly into the
background enters this state instead of the inactive state.
5. Suspended
: The app is in the background but is not executing code. The
system moves apps to this state automatically and does not notify
them before doing so. While suspended, an app remains in memory but
does not execute any code.
When a
low-memory condition occurs, the system may purge suspended apps
without notice to make more space for the foreground app.
fig. Change of App States
Most state
transitions are accompanied by a corresponding call to the methods of
your app delegate object. These methods are your chance to
respond to state changes in an appropriate way. These methods are
listed below, along with a summary of how you might use them.
application:willFinishLaunchingWithOptions:
— This method is your app’s first chance to execute code at launch time.application:didFinishLaunchingWithOptions:
—This method allows you to perform any final initialization before your app is displayed to the user.applicationDidBecomeActive:
—Lets your app know that it is about to become the foreground app. Use this method for any last minute preparation.applicationWillResignActive:
—Lets you know that your app is transitioning away from being the foreground app. Use this method to put your app into a quiescent state.applicationDidEnterBackground:
—Lets you know that your app is now running in the background and may be suspended at any time.applicationWillEnterForeground:
—Lets you know that your app is moving out of the background and back into the foreground, but that it is not yet active.applicationWillTerminate:
—Lets you know that your app is being terminated. This method is not called if your app is suspended.