When is applicationDidBecomeActive called?

Does anyone explain when the applicationDidBecomeActive method is called? What is the purpose of this method? also when calling applicationDidBecomeActive ?

+7
ios
source share
2 answers

Understand iOS statuses and transitions

States

Does not work . The application does not work.

Inactive . The application runs in the foreground, but does not accept events. An iOS application can be placed in an inactive state, for example, when you receive a call or SMS message.

Active . The application runs in the foreground and accepts events.

Background . The application runs in the background and executes code.

Suspended The application is in the background, but the code is not executing.

The seven most important application delegation methods

The operating system calls certain methods in the application deletion to facilitate the transition to and from various states. The seven most important application delegation methods that a developer must follow are:

Applications: willFinishLaunchingWithOptions

The method to call when the startup process starts. This is the first opportunity to execute any code in the application.

Applications: didFinishLaunchingWithOptions

The method is called when the startup process is almost complete. Since this method is called before any application window is displayed, this is the last opportunity to prepare the interface and make any final settings.

applicationDidBecomeActive

Once the application becomes active, the application delegate will receive a callback notification message through the applicationDidBecomeActive method.

This method is also called every time the application returns to active state from the previous switch to inactive from the resulting phone call or SMS.

applicationWillResignActive

There are several conditions that invoke the applicationWillResignActive method. Each time a temporary event occurs, such as a phone call, this method is called. It is also important to note that “quitting the iOS application” does not terminate the processes, but transfers the application to the background.

applicationDidEnterBackground

This method is called when the iOS application is running, but is no longer in the foreground. In other words, the user interface is not currently displayed. According to the Apple UIApplicationDelegate Protocol Reference, an application takes about five seconds to complete tasks and return. If the method does not return within five seconds, the application terminates.

applicationWillEnterForeground

This method is called an application that prepares to move from the background to the foreground. However, the application does not move to the active state without calling the applicationDidBecomeActive method. This method allows the developer to restore the settings of the previous running state before the application becomes active.

applicationWillTerminate

This method notifies the delegate of your application when a termination event was triggered. Pressing the home button no longer exits the application. The power to exit the iOS application or turn off the device starts the applicationWillTerminate method. This is an opportunity to save application settings, settings and user settings.

need more information link link1 or apple link2

+29
source share

When the user uses the application, he is in an active state. The user switches to the inactive state from the resulting phone call or when the center of the pop-up notification is pulled out or when the main screen is pressed (this is when the application is announced in the background), and then the application opens again (this is when the application returns to the foreground state).

Therefore, every time a user switches from an inactive state to an active state applicationDidBecomeActive, this delegate is called

+2
source share

All Articles