[Translation] design ideas and methods for Activity and Task

Source: Internet
Author: User
Tags home screen

Phantom journey

Activity and Task are the most basic applications in the Android Application Framework architecture. Developers must understand their usage and development skills. This article uses a large amount of space and uses examples to explain their basic principles (underlying principles) and Architecture (mechanisms) Step by step. For example: navigation, Multitasking, activity re-use, intents, and activity stack... Most of its application modules. It focuses on how to more accurately reflect the convenience and efficiency of user interaction during the development process, and also helps analyze the problems that Designers and Developers face during the development process.

Some of the examples involved in this article are the applications that come with the Platform (such as dialup programs), and some representative applications in the Google product line (such as Google Map ). We recommend that you use Emulator or Android-powered device to test the effect of the Instance. This helps you better understand the meaning of some modules. (Note: The hardware may not support certain functions, so some instances may not be able to be browsed on your test machine)

First, you need to understand some basic modules:
  • Html "target = _ blank>Applications
  • Acitivities
  • Activity Stack
  • Tasks

The above four modules are very important for understanding this article. Next we will briefly introduce their meanings and usage one by one (you can also directly view the official documentation through its link ).

Applications

Any Android Application is basically composedActivitiesWhen a user interacts with an application, the Activities that a user contains have a close logical relationship, or they independently process different responses. 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.

Activities

As mentioned above, Activities are the main component of Applications. In fact, it can be more specifically understood that Application is just an abstract label, which associates some Activities in the system, collaborate to fulfill specific user needs. 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.

Most of the interactions between users and applications are completed through the GUI. On the Android platform, you can define the GUI in two ways. XML can be used to preset static GUI elements, you can also dynamically define GUI elements in the Activity class. These two methods are driven by Activity and respond to user interaction events. After the Application is started, at least oneActivityThe instance is created.

The Activity body consists of two main parts: Content (data) and response to user interaction events. List a Dialer example, which includes four parts: The Dialer main interface, Address Book, viewing contact information, and adding new contacts.

The following lists more representative Applications and their Activities:

  • Email-activities to view folders, view list of messages, view a message, compose a message, and set up an account
  • Calendar-activities to view day, view week, view month, view agenda, edit an event, edit preferences, and view an alert
  • Camera-activities for running the camera, viewing the list of pictures, viewing a picture, cropping a picture, running the camcorder, viewing the list of movies, and viewing a movie
  • Game-one activity to play the game, typically another for setup
  • Maps-one activity to view a location on a map, a second for lists (such as turn list or friend list), and a third for details (friend location, status, photo)

The Application is basically composed of four modules: Activity, Service, Content Provider, and Broadcast Receiver.ActivityIs the main body of the application.

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 this navigation function to return the previous Activity (by "Back" of the console ").

Each time a new Activity is started, it is added to the Activity Stack. You can easily return the previous Activity to the Home Screen. After arriving at the Home Screen, you will no longer be able to view the stack record (as the saying goes: Androidres.com ). 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.

Tasks

On the Android platform, tasks can be understood as multiple Activities working together to complete an Application, regardless of the specific Application of Activities. The following figure shows the relationships among Applications, Tasks, and Activities.(Provided by Androidres.com):

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.