The iOS program enters the background, including the research that the user pulls a shortcut menu and causes the program to become inactive.

Source: Internet
Author: User

The iOS program enters the background, including the research that the user pulls a shortcut menu and causes the program to become inactive.

When I was using an App today, I suddenly found that the program video was being played while pulling the menu! It aroused my interest.

First, list two methods. The first method is the proxy of AppDelegate, which is called when the program enters the background.
- (void)applicationDidEnterBackground:(UIApplication *)application NS_AVAILABLE_IOS(4_0);
The second method is to register the system notification. The name is UIApplicationWillResignActiveNotification, which is called when the program is released.
    [[NSNotificationCenter defaultCenter] addObserver:self                                             selector:@selector(applicationWillResignActive:)                                                 name:UIApplicationWillResignActiveNotification                                               object:nil];
Developers need to implement
- (void)applicationWillResignActive:(UIApplication *)application
The following are common operations for programs to enter the background or become inactive. 1. Click the home key and the program enters the background: Call applicationWillResignActive and then call applicationDidEnterBackground.
2. Double-click the home Key and add the program to the task manager. Only applicationWillResignActive is called. If you click another program, other programs will enter the foreground. This App calls applicationDidEnterBackground
3. Pull up, drop-down menu, the program is still in the foreground: Only applicationWillResignActive is called

When you watch a video on the [Netease news] App, [Netease Video] Only processes the first case, that is, to pause the video. However, you do not process the remaining cases and the video continues to be played.

This should be a refinement of user interaction, which aroused my interest. Sometimes, I just use a shortcut menu to make some simple switches, such as opening a flashlight, turning on wifi, and turning off rotation. You do not want the video to stop. There are some apps on the market. In these three cases, they are paused first and then restored at the front end, but they will be stuck visually.

(To be improved)

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.