Four Common scenarios of Activity and four scenarios of activity

Source: Internet
Author: User

Four Common scenarios of Activity and four scenarios of activity
1. Common singleInsyance application scenarios:

① Mobile phone dialing interface (mobile phone dialing interface is used for numbers such as QQ and SMS)

② Social APP sharing page (QQ, zhihu)

--External App calls the entry of its own client programThe singleInstance startup mode is used.

The following uses the social sharing page as an example:

The above picture depicts a total of 7 pictures from the album sharing image to the friend process, 7 steps:

① Open the Xiaomi mobile album APP and select an image;

② Select an image and send it to it;

③ The page appearsSending selection Interface;

④ Click "File Transfer assistant" to bring up the send confirmation dialog box;

⑤ Click "send" to enter the file transfer Assistant dialog box and complete the photo sending;

6. Click the back button (the meter 4 used by the author has a return key) and return to the main activity interface;

7. Click back again to exit the APP and return to the original page of the album APP.

Excuse me:The most criticalWhich Activity is it? Which startup mode is used? Why?

A: The most important thing is the Activity shown in the third figure. The sending selection interface has the singleInstance startup mode. Under normal circumstances, only the active interface in this startup mode will be set as a shared Activity to facilitate sharing between other activities and other applications.

Interested readers can think about two issues: 1) What is the way they roll back by pressing the back key twice? 2) What is the difference between sending an image to a friend internally and sending it to a friend? 3) what happens when I open the music app and share music to my friends?

Ii. Common scenarios of singleTask:

InThe App is suitable for serving as the entry point of the program.. From the above introduction, we can see that the startup mode is used to call a large number of Activity pages in our App project. Which Activity is used in the project? Of course, the first interface HomeActivity calls a lot, so inFirst Interface ActivityThe Startup Mode of is suitable for changing the startup mode. Of course, other activities that use more resources should also be set to the startup mode.

① Browser homepage Activity, the entire task stack has only one instance, saving memory;

② Shopping APP baby display interface 01, interface 02 confirm the order, interface 03 pay, if the payment is successful, it will automatically jump to interface 01, if the payment fails, return to interface 02, at this time, the singleTask startup mode is used to restart 01.

Iii. Common singleTop scenarios:

① An Yiyun classroom APP often receives multiple notifications. Click one of them to start playing the video. After reading the video, click the second notification to refresh the video on the original interface, however, an open action may occur. The singleTop startup mode is used for playing the interface with good user experience;

② The toutiao news app on a day is the same as the notification-related operations;

③ Note/novel APP setting interface. For example, if the font size is set for the first time, and then you start to write/read the text, the font size is too small. The second time you open the settings, to increase the font size. At this time, the startup mode of the interface is set to singleTop, because this operation is usually not frequent, and can be re-created even if there is no instance. It is not appropriate to use other startup methods.

Iv. Common Use Cases of standard:

In this mode, there can be multiple identical instances and multiple identical activities can be superimposed. Therefore, we generally do not use this startup method, in this way, not only re-constructing the Activity object will cause time consumption, but will also cause a waste of memory.

However, it is common in apps where "some content may be changed at any time", such as bank apps. Opening "accounts", "credit cards", and "Financial Products" in turn will find that, to open each interface, you must refresh the network in sequence, request the latest data, and then open it one by one, even if the Activity opened three seconds ago is re-opened, the network needs to be refreshed. It can be inferred that the startup mode of the interface is the standard mode.

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.