I. Task
To explain what is a task in Android, You need to mention the application and Activity.
Activity: the most basic application component in Android. An Activity is usually a separate screen used to present data and interact with users.
Application: for example, QQ Software is an application, usually composed of multiple activities.
With the above two concepts, you can understand the task well. An Android task usually involves multiple activities, which may belong to different applications ).
From the Activity perspective, a task is the stack of the Activity.
Activity and task
The association between the Activity and the task, and the behavior of the Activity in the task are all set between a series of flags and a series of attributes of the <Activity> element of the Activity in the manifest file in the Intent object that starts the Activity. interaction control.
Intent flags:
FLAG_ACTIVITY_NEW_TASK
FLAG_ACTIVITY_CLEAR_TOP
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
FLAG_ACTIVITY_SINGLE_TOP
<Activity> attributes:
TaskAffinity
LaunchMode
AllowTaskReparenting
ClearTaskOnLaunch
AlwaysRetainTaskState
FinishOnTaskLaunch
Start the task:
When an Activity specifies an "android. intent. action. MAIN "as action," android. intent. category. when LAUNCHER is used as the intent filter of a category, it is set as the entry point of a task.
If you do not want the user to return an Activity again, set finishOnTaskLaunch to "true"
2. Android Process
The process where the component runs is controlled by the manifest file. Component elements such as <Activity>, <service>, <javaser>, and <provider> all have a process attribute to specify the process in which the component should run. <Application> the element also has a process attribute that sets the default process attribute values for all components.
3. Android thread
Android threads are created in the code using standard java thread objects. Android provides many classes to facilitate thread management: logoff is used to run a message loop in the thread, handler is used to process messages, and handlerthread is used to enable threads in a message loop.
In fact, there is no difference between android processes and threads and in linux.