Android manifest file specific explanation (vi)----<activity> Node properties

Source: Internet
Author: User
Tags switches home screen

1.android:allowtaskreparenting


android:allowtaskreparenting is a task-tuning property that indicates whether the activity defined by the application will be able to move from the task being launched to a task with the same affinity when the task is sent to the foreground again.


Read the previous post all know, explain this property, why do you want to mention it here? Because it overlaps with the android:allowtaskreparenting property of <application>, when this property is provided for the activity being configured, its default value first comes from <application > node. Assuming that the property is not configured on the <application> node, FALSE is its default value.


Typically, when an activity is started, the Activity Management Service generates a task for the activity and associates the activity with it.

There may be multiple activity in a task, which is arranged in a certain order in this task, and we can use this property to force it to become the top activity again for this task.

When the current task is no longer displayed, that is, when the activity-related task is not displayed in the foreground, you can use this feature to force the activity to move to a task with the same affinity (the task defined by the Taskaffinity attribute). A typical use is to move an application's activity to the main task of an application.


For example, suppose we receive a text message (MMS application) that includes a phone number. At this point you can click the phone number to start the Dial-up shortcut interface.

However, this dial-up interface is an activity for the contact application. In this scenario, it may become an activity in the tasks that the MMS application initiates. And is located on the top level of the task. Let's say it once again navigates to the contact's task. We don't see the dial-up interface again when we start the SMS task again.


The affinity for activity is defined by the Taskaffinity attribute. The affinity of a task is determined by reading the affinity of the root activity of the current task.

So. According to the definition. Root activity is always in the same affinity task. Because of the requirements of some requirements, some activity startup modes (defined by the Launchmodel attribute) are Singletask and singleinstance, and such activity can only be located at the bottom of the task. Therefore, to use the Allowtaskreparenting property to adjust the task to which the activity belongs, the startup defaults to only the "standard" and "Singletop" modes.



2.android:alwaysretaintaskstate


This property indicates whether the state of the task in which the activity resides is saved by the system, assuming yes. The value is true, assuming that the configuration is false. Indicates that, under certain circumstances, Android will start the task in its initial state. The default value for this property is false. It is important to note that. This property only works on the root activity of the task, and all other activity is ignored.


When the user chooses to display the task again. Normally, the system will clean up any activity other than the root activity in the task.

This typically means that the user does not operate on the task within a certain time limit, such as within 30 minutes. Conversely, if the property is configured to True, the system always displays the task in its final state, regardless of how the user returns.



3.android:cleartaskonlaunch


This property indicates whether all other activity will be removed from the task except the root activity in the task.

If you want to keep only the root activity at startup, set the value of this property to true, otherwise false. The default value for this property is false. This property is only meaningful for starting the root activity of a new task.

When configured to True, each time the user starts the task again. The request is always handled by the root activity of the task.


Assuming that both the property and the allowtaskreparenting are true, you can again become the parent task regardless of what activity will be moved to a task with the same affinity. Then the remaining activity is destroyed.



4.android:configchanges


In some device configurations (for example, screen orientation. When a font size, network type, etc.) changes, the activity is started again to fit the new configuration. This is the system behavior. And Android is the same as the application provides a means to prevent such behavior, if you do not want to be due to some configuration changes in the activity restart, you can configure this property and select the configuration you want to block. Assuming that you have configured and selected the configuration you care about, the activity does not restart when these configurations change, but instead notifies the application through the onconfigurationchanged () callback method that the configuration has changed.


Note: if not necessary. You should avoid using this property


The following table lists the valid values for this property, and to set multiple, use the ' | ' Cut it open and you can.


Value Descriptive narrative
Mcc IMSI Mobile Country Code Changes----The MCC information in the SIM is updated
Mnc IMSI mobile Network Code----SIM's MNC information is updated
Locale The language environment has changed----the user has selected a new language through the settings function. Touch screen changes
Touchscreen Touch screen Changes
Keyboard The keyboard type has changed----For example, the user has access to an external keyboard
Keyboardhidden Keyboard visibility has changed
Screenlayout Screen layout has changed
Fontscale Font scaling factor has changed-----user selects a new font size by setting the module
Uimode The user interface pattern has changed-----The user interface changes when the user places the device on the seat or when the night mode changes.
Orientation The screen orientation has changed----the user flipped the device
Note: If the application is positioned at API Level13 or higher, the screensize configuration should also be declared. Because when the device switches between landscape and portrait, it also changes
ScreenSize The currently available screen size has changed, indicating changes in the currently available dimensions. Relates to the current aspect ratio. This happens when the user switches between landscape and portrait. But. Assuming the application is positioned at API Level12 or lower, activity will always handle the configuration on its own.

Smallestscreensize The physical screen size has changed.

This indicates a change in size. No matter the direction, it only changes when the actual physical screen size changes (such as switching to external display). Changes to this configuration respond to a change in the Smallestwidth configuration. However, assuming the application is positioned at API Level12 or lower, activity always handles changes to that configuration on its own



All of these configuration changes can affect the application's choice of resource files. So. When Onconfigurationchanged () is called, it is often necessary to get all the resources (including view layouts and pictures, etc.) again, in order to handle these changes correctly.


It is important to note that if we do not implement the onconfigurationchanged () callback, then the activity will be destroyed and created again.



5.android:enabled


In general, each activity is instantiated by the activity framework, but you can configure this property to limit the behavior of the system.

This property indicates whether the activity can be instantiated, true to indicate that the system is instantiated, or false. The default value of this property is true.

For each activity child class. It is always instantiated before it is first executed. This step is necessary. We can use this property to control the behavior of the Android framework to instantiate activity, but doing so is risky, so you are not advised to do so.



6.android:excludefromrecents


The Android framework maintains a list of applications called "recent executions" to facilitate application switching. This property indicates whether the application should exclude activity from the list of recently executed applications, assuming exclusion. Is true. otherwise, false.

The default value for this property is false. The premise of this property is that the activity is the root activity of a task.



7.android:exported


This property indicates whether the activity can be started by a component in another application, assuming it can. True, otherwise false.

If False, the activity can only be started by a component of the same application or an application with the same user ID.


It is important to note that if you try to launch other application components from your application, you must start with a new task (NewTask) without using this property



8.android:finishontasklaunch


This property is defined whenever the user starts the Activity task again (select the task on the Home screen). Whether or not an instance of the activity should be destroyed (or terminated). True if it should be destroyed, or false. The default value for this property is false.



9.android:hardwareaccelerated


This property refers to whether hardware acceleration should be initiated for the activity, or true if it should start, otherwise false.

The default value is False.


Note: Not all OpenGL 2D operations will be accelerated. Assume that the hardware acceleration renderer is enabled. Test your application to make sure it can use the renderer without generating an error.



10.android:icon


It represents activity and icons. The icon is displayed to the user when the activity is displayed.

Like what. An icon for the activity that demonstrates the sample task, or an icon on the desktop.


The property must be set to a picture resource reference. Assumptions are not set. Use the Icon property on the <application> node.



11.android:label


This property is used to describe a label describing the activity, which is typically displayed along with the activity icon.


Assuming that the property is not set, the value set by the Label property on the <application> node is used.



12.android:launchmode


This attribute describes how the activity should be started. In the intent object. There are 4 modes of working with the activity logo, each of which is: Standard,singletop,singletask and singleinstance. The default mode is standard.


For example, the following table. There are two types of patterns. One category is standard and singletop. Another category is Singletask and singleinstance. Activity with standard and Singletop startup modes can be instantiated multiple times.



Use of the situation Startup mode Multiple instances? Note
Normally start mode Standard Is Default. The system always creates a new instance of the activity in the target task and puts intent into the instance in order.
Singletop Conditional. Assume that an instance of the activity already exists at the top of the target task. The system sends the intent to the instance by calling the Onnewintent () method. Instead of creating a new instance of the activity
Special Boot Mode Singletask Whether The system creates the activity on the root of the new task. Assuming an instance already exists, the system sends intent to the activity by calling the Onnewintent () method, which agrees to create a new activity in the activity root task
SingleInstance Whether The same as Singletask. The activity is always individual and the only member of its task, except that the system does not start, no matter what other activity to the task that holds the instance.



In contrast, the activity in both modes of singletask and singleinstance can only initiate a task they stay on the root of the activity stack. In addition The device saves only one instance of the activity at a time.


Standard and Singletop models are only different in one respect. In Satndard mode, an activity new instance is instantiated each time to respond to this intent, each instance handling a intent.

Similar to this is the. A new instance of activity in Singletop mode can also be created to handle the new intent.

But. Suppose that the target task already has an instance of activity at the top of its stack. The intent (callback Onnewintent () method) is processed using an instance of the existing activity. Instead of creating a new instance. In other cases, assume that an existing instance of activity in Singletop mode is in the target task rather than at the top of the stack. Or assume it's at the top of the stack rather than the target task. Creates a new instance and overrides it on top of the activity stack.


The Singletask and SingleInstance modes also have different startup characteristics.

Activity in Singletask mode agrees that other activity becomes part of its task, always on the root of its own task, but other activity can be initiated into the task.

On the one hand, activity in SingleInstance mode does not agree with other activity as part of its mission. It is the only activity in the task. Assuming it starts with an activity, the activity is assigned to a different task, like Flag_activity_new_task in intent.



13.android:multiprocess


This property indicates whether an instance of activity can be executed in the application process where the component that started it is located. True if it is possible, otherwise false. Its default value is False.



14.android:name


This property represents the class name of the activity, which is a subclass of activity, and its attribute value should be a standard Java class name (such as Com.example.liyuanjing.ManiActivity). We can also identify it as a class abbreviation. For example, the first letter of the name is a dot (e.g.. maniactivity), then it is appended with the package name specified by the <manifest> element, This becomes com.example.liyuanjing.ManiActivity (if the package is named Com.example.liyuanjing).

This is completely done by the system, and we don't need to be concerned with the details of the process, but this property is mandatory and does not provide a default value.



15.android:nohistory



This property is used to set the activity to leave the user. and whether it should be removed from the activity's stack when it is no longer visible on the screen. True if it should be deleted. otherwise, false. The default value is False.


True means that the activity will not leave traces of history. It will not keep the data in the activity stack for the task, so the user will not be able to return to the activity.



16.android:permission


Represents a permission name. Assume that the caller of startactivity () or Startactivityforresult () has not been granted the specified permission. The startup fails.


Assuming that the property is not set, the permissions set by the <application> element's permission property should be applied to the activity. If both properties are not set, activity is not protected by permissions.



17.android:process



The property represents the name of the process that the activity executes.

Usually. All components of an application are executed in the default process created for the application. The process property of the <application> element enables a different process to be set for all components. However, each component can override the value of this property, which enables the application to be deployed across multiple processes.


Assuming that the name of the property is assigned begins with a colon (:), a new process is created for the application to be private when a new process is required and the activity executes in that process.



18.android:screenorientation


This property represents the direction in which the activity is displayed (for example, Portrait, landscape), which is a random character in the following table.


The
Value description
unspecified default value, select direction according to Gravity sense
user User's current preferred orientation
behind and activity the same direction
Landscape Landscape
Portrait portrait
reverselandscape                       &NBSP;&NBSP landscape in the opposite direction from normal horizontal
reverseportrait Vertical in the opposite direction of normal vertical
sensorlandscape can only be horizontal, but can be based on gravity sensing to determine whether it is normal or reversed horizontal
sensorportrait can be portrait-wise. However, a vertical
sensor direction is determined by the device direction sensor to determine whether it is normal or inverted based on Gravity sensing. The direction of the display depends on how the user holds the device, and the direction changes when the user flips the device. Some devices do not flip to all 4 possible directions by default. To agree that you can flip to all 4 directions, you can use Fullsensor
fullsensor direction from device orientation to random one in 4 directions
nosensor Non-inductive mode





19.android:statenotneeded


This property indicates whether the activity can be terminated and successfully restarted without saving its state.

This property is true if the activity can be restarted without reference to the previous state, assuming that the ability to refer to the previous state is restarted. is false. The default value is False.


Typically, we call the Onsaveinstancestate () method to save the state of the current activity until the activity is temporarily closed. This method stores the current state of the activity in the bundle object, which is passed to the OnCreate () method in the form of a number of parameters when the activity is restarted. Assuming that the property is set to True, Onsaveinstancestate () is not called. and OnCreate () is passed null. This is the same thing you did when the activity first started.



20.android:taskaffinity


This property indicates a task that has affinity for the activity. Activity with the same affinity is conceptually the same task (the task defined by the application by default). The affinity of a task is determined by the affinity of its root activity.



21.android:theme


This attribute refers to a reference that defines an overall theme-style resource for activity.

The so-called style contains the font type, the overall style and so on. Using this property can make our activity more unified and beautiful in general.


Assuming that the property is not set, activity inherits the theme set by the application as a whole. Detailed visibility of the theme property of the <application> element. Assuming that the theme property is also not set, the default system theme is used.



22.android:windowsoftinputmode


This property represents how the main form of activity interacts with a form that includes a soft keyboard on the screen.

Setting this property will affect two things.


① The state of the soft keyboard. Whether the soft keyboard is hidden when activity gets the input focus.


② Adjustment of the activity main form. Whether the form is resized smaller to make room for the soft keyboard, or whether its contents are moved so that the current focus is visible when a part of the form is overwritten by a soft keyboard.


This property is either a value from the following table, or the state ... Values and adjust ... A combination of values. The assumption is a combination of multiple values. Use (|) to separate them, such as


<activity android:windowsoftinputmode= "Statevisible|adjustresize" .....>


The values set here (Statevisible and adjustresize) override the values set in the theme.


value descriptive narrative
stateunspecified does not have the state of the specified soft keyboard (whether hidden or visible). The

System will select an appropriate state or a dependency on the definitions in the theme to set. This is the default setting for soft keyboard behavior.

stateunchanged Soft keyboard remains in whatever state it was last
Statehidden The soft keyboard is visible when the user chooses activity
Statealwayshidden The soft keyboard is always hidden when activity has input focus (for example, when the edit box has the focus).
statevisible The soft keyboard is visible when the user enters the activity's main form
Statealwaysvisi ble        When the user chooses activity. Soft keyboard visible
adjustunspecified activity's main form resizing to make room for a soft keyboard
adju Stresize The main form of activity is always adjusted to make room for the soft keyboard on the screen
adjustpan The main form of the activity will not be adjusted to the screen Soft keyboard to make room for

Android manifest file specific explanation (vi)----&lt;activity&gt; Node Properties

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.