Relationship between Android Application Task Activities

Source: Internet
Author: User

What is Android Application?

In short, an apk file is an Application.

Any Android Application is basically composed of some Activities. When a user interacts with an Application, some of the Activities it contains have close logical relationships, or each of them processes different responses independently.

These Activities are bundled together into an Application that handles specific requirements, and the extension named "pai.apk" is included in the file system.

Apps on the Android platform, such as Email, Calendar, Browser, Maps, Text Message, Contacts, Camera, and Dialer, are independent Apps by default.

 

The Installation Process of the Application can also be simply understood as importing the wrapped Activities to the current system. If the same Activities already exists in the system, it will be automatically associated, the same Activities will not be installed repeatedly to avoid resource waste.

The Application uninstall process also checks whether the associated Activities are associated with other Application labels. If only the current Application is used, the Application will be completely removed, on the contrary, no operation is performed.

 

As we already know, the Application is basically composed of four modules: Activity, Service, Content Provider, and Broadcast explorer. Activity is the main body of the Application.

 

What is Activity Stack?

When operating applications, you sometimes need to call multiple Activities to fulfill the requirements. For example, to send an email program, first enter the main interface of the email, and then start a new Activity to enter the content of the new email, you can also call up the contact list to insert Recipient Information. During this operation, the Android platform has a mechanism dedicated to managing the Activities stack, which can easily record Activities instances linearly. When an operation is completed, you can use the navigation function to return the previous Activity (by pressing the "Back" button on the console ).

Each time a new Activity is started, it is added to the Activity Stack. You can easily return to the previous Activity until the Home Screen. After arriving at the Home Screen, you will no longer be able to view the stack record (as the saying goes: In the beginning ). If the current Task is aborted (Interrupting the task), other operations are started after it is returned to the main interface of the system. If you want to return to the previous Task for further execution, you only need to start the Root Activity of the Task through the Application launcher or shortcut on the main interface again to return the status of the Task during suspension and continue the execution.

Compared with Views, Windows, Menus, and Dialogs, Activity is the only data that can be recorded in the History stack, therefore, when the application you designed requires the user to enter the next-level interface B from interface A, and the user needs to return A again after the operation is completed, A must be considered as the Activity, otherwise, it cannot be returned from the history stack.

 

What is a Task?

When we need an Activity to start another Activity, another Activity may be defined in different applications.

For example, suppose you want to display street views in some places in your application. Here, an Activity can do this. Therefore, all you need to do is to add necessary information to the Intent object and pass it to startActivity (). Map Browsing will display your map. When you press the BACK key, your Activity will appear on the screen again.

For users, it seems that map browsing is the same as your Activity and belongs to the same application, even if it is defined in other applications, and run in the Process of the application.

Android stores these two activities in the same Task to demonstrate this user experience. Simply put, a Task is an "application" for user experience ". 
It combines related activities and manages them in stack mode (that is, the previously mentioned Activity Stack). This is the Task.

 

On the Android platform, tasks can be easily understood as the collaboration between multiple activities to complete an Application, no matter which Application the Activity belongs,

You can better understand the relationship among Application, task, and Activity:

 

What is the use of tasks?

When we use Android phones, we will know the following scenarios:

Suppose we are reading books with IReader first, from book selection to the reading interface of specific books, there are several activities. Every Activity we click is placed in the Activity Stack corresponding to the read Task. This allows us to return the previous Activity through the rollback key.

When we read half of it, we wanted to see Sina Weibo and press the Home Key to exit IReader.

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.