App States Flashcards
When an app is said to be in not running state?
An app is said to be in ‘not running’ state when:
- it is not launched
- it gets terminated by the system during running
Assume that your app is running in the foreground but is currently not receiving events. in which state would it be in?
An app will be in inactive state if it is running in the foreground but is currently not receiving events. An app stays in inactive state only briefly as it transitions to a different state.
Give example scenarios when an application goes into inactive state?
An app can get into inactive state when the use locks the screen or the system prompts the user to respond to some events e.g. SMS message, incoming calls etc.
When is an app said to be in active state?
An app is said to be in active state when it is running in foreground and is receiving events.
Name the app state which it reaches on its way to being suspended?
An app enters background state briefly on its way to be suspended
Assume that an app is not in foreground but is still executing code. In which state will it be in?
Background state
An app is loaded into memory but is not executing any code. In which state will it be in
An app is said to be in suspended state when it is still in memory but is not executing any code.
Assume that system is running low on memory. What can system do for suspended apps?
In case system is running low on memory, the system may purge suspended apps without notice.
How can you respond to state transitions on your apps?
On state transitions can be responded to state changes in an appropriate way by calling corresponding methods on app’s delegate object.
For example:
applicationDidBecomeActive method can be used to prepare to run as the foreground app.
applicationDidEnterBackground method can be used to execute some code when app is running in the background and may be suspended at any time.
applicationWillEnterForeground method can be used to execute some code when your app is moving out of the background
applicationWillTerminate method is called when your app is being terminated.
List down app’s state transitions when it gets launched
Before the launch of an app, it is said to be in not running state. When an app is launched, it moves to the active or background state, after transitioning briefly through the inactive state
Who calls the main function of your app during the app launch?
During app launching, the system creates a main thread for the app and calls the app’s main function on that main thread. The Xcode project’s default main function hands over control to the UIKit framework, which takes care of initializing the app before it is run.