Android Inventory file details (vi)----<activity> Node properties

Source: Internet
Author: User
Tags home screen

1.android:allowtaskreparenting


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


Read the previous post all know, explained 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. If 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 back into the top activity of 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 the activity of one application into the main task of another application.


For example, if we receive a text message (the MMS application) that contains a phone number literal, 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, and in this scenario it may become an activity in the task that the MMS application initiates and is located at the top level of the task. If it is relocated to the contact's task, we will not see the dial-up interface When we restart the SMS task.


The affinity of the activity is defined by the Taskaffinity attribute, and the affinity of the task is determined by reading the affinity of the current task root activity. Therefore, by 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, 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 default is limited to the two modes "standard" and "Singletop".



2.android:alwaysretaintaskstate


This property indicates whether the state of the activity's task is saved by the system, if so, its value is true, and if configured to false, it means 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 will be ignored.


When the user re-chooses to display the task, the system normally cleans up other activity in the task except the root activity. This usually means that the user does not operate on the task within a certain time limit, for example, within 30 minutes. Conversely, if the property is configured to True, the system always displays the task in the last state of the task, regardless of how the user returned it.



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, the request is always handled by the root activity of the task whenever the user starts the task again.


If both the property and the allowtaskreparenting are true, any activity that can be re-parented will be moved to a task with the same affinity, and the remaining activity is destroyed



4.android:configchanges


When certain device configurations (such as screen orientation, font size, network type, and so on) change, the activity will be restarted to fit the new configuration, which is the system behavior. Android also provides an application with a means to prevent this from happening, and if you don't want to have an activity restart because of a configuration change, you can configure this property and select the configuration you want to block. If you configure and select 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: You should avoid using this property if it is not necessary


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


Value Describe
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 User interface mode has changed-----user interface changes when the user places the device on the cradle or when the night mode changes
Orientation The screen orientation has changed----the user flipped the device
Note: If the application is located in API Level13 or higher, you should also declare the screensize configuration, because it also changes when the device switches between landscape and portrait
ScreenSize The currently available screen size has changed, indicating changes in the currently available dimensions. Relates to the current aspect ratio. This can also happen when the user switches between landscape and portrait. However, if 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 that changes in size, regardless of direction, are only changed when the actual physical screen size changes (such as switching to external display). Modifications to this configuration respond to a change in the Smallestwidth configuration. However, if the application is positioned at API Level12 or lower, the activity always handles modifications to that configuration on its own



All of these configuration changes can affect the application's choice of resource files. Therefore, when onconfigurationchanged () is called, it is often necessary to retrieve all of the resources (including view layouts and pictures, etc.) 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 recreated.



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 subclass of activity, it is necessary to instantiate the class before it is first run. 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 "recently run" to facilitate application switching. This property indicates whether the application should exclude activity from the list of recently run applications, or True if excluded, false otherwise. 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, or true if possible, 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 refers to whether the instance of the activity should be destroyed (or terminated) whenever the user starts the activity task again (on the home screen), 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. If you enable the Hardware acceleration renderer, 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. For example, an activity icon for a sample task, or an icon on the desktop.


The property must be set to a picture resource reference, and if not set, the Icon property on the <application> node is used.



11.android:label


This property is used to describe a label for the activity, usually shown along with the activity icon.


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



12.android:launchmode


This property describes how the activity should be started. In the intent object, there are 4 modes that work with the activity flag, namely: Standard,singletop,singletask and SingleInstance. The default mode is standard.


As the following table, there are two types of patterns, one is standard and singletop, the other 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. If 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. If an instance already exists, the system sends intent to the activity by calling the Onnewintent () method, which allows a new activity to be created in the Activity root task
SingleInstance Whether As with Singletask, the activity is always individual and the only member of its task, except that the system does not initiate any other activity to the task holding the instance.



In contrast, activity in both modes of singletask and singleinstance can only start 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 modes are only different in one respect. In Satndard mode, a new instance of activity is instantiated each time to respond to this intent, each of which processes a intent. Similarly, a new instance of activity in Singletop mode can also be created to handle the new intent. However, if the target task already has an instance of activity at the top of its stack, the intent (callback Onnewintent () method) will be processed using an instance of the existing activity, instead of creating a new instance. In other cases, if an existing instance of activity in Singletop mode is in the target task instead of the top of the stack, or if it is in the top of the stack instead of the target task, a new instance is created and overwhelmed on top of the activity stack.


The Singletask and SingleInstance modes also have different startup characteristics. Activity in Singletask mode allows other activity to be part of its task, always on the root of its own task, but other activity can be launched into the task. On the other hand, activity in singleinstance mode does not allow other activity to be part of its task, it is the only activity in the task. If it launches another 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 run in the application process where the component that started it is, or 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, such as the first letter of the name is a point (for example. maniactivity), then it is appended with the package name specified by the <manifest> element, It becomes com.example.liyuanjing.ManiActivity (assuming the package name is com.example.liyuanjing). This is done entirely 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 whether it should be removed from the activity's stack when the user leaves the activity and it is no longer visible on the screen. True if it should be removed, 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. If the caller of startactivity () or Startactivityforresult () has not been granted the specified permission, the start fails.


If this 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



This property represents the name of the process that the activity runs on. Typically, all components of an application run in the default process that is created for the application. The process property of the <application> element can set up a different procedure for all components, but each component can override the value of this property, thus enabling the application to be deployed across multiple processes.


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



18.android:screenorientation


This property represents the direction in which the activity is displayed (such as portrait, Landscape), which is a value that can be any of the characters in the following table.


The The The
Value description
unspecified default value, select direction based on Gravity sensing
user User's current preferred orientation
behind and activity in 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 landscape, but can be determined by gravity sensing to be normal or reversed horizontal
sensorportrait can be longitudinal, but can be determined by gravity sensing to be normal or inverted vertically
sensor direction is determined by the device orientation sensor. 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 allow rollover to all 4 orientations, you can use the Fullsensor
fullsensor direction to determine the direction of the device as any of the 4 directions in a
nosensor Non-inductive mode





19.android:statenotneeded


This property indicates whether the activity can be terminated and whether it can be restarted successfully without saving its state. This property is true if the activity can be restarted without referencing to the previous state, or False if a reference to the previous state is required to be restarted. The default value is False.


Typically, before you temporarily close the activity, we call the Onsaveinstancestate () method to save the state of the current activity. This method stores the current state of the activity in the bundle object, which is passed to the OnCreate () method as a parameter when the activity is restarted. If the property is set to True, Onsaveinstancestate () is not called, and OnCreate () is passed null, as it did when the activity was 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 a holistic theme-style resource for activity. The so-called style includes font type, overall style and so on. Using this property can make our activity more unified and beautiful in the whole.


If this property is not set, activity inherits the theme set by the application as a whole, and the theme property of the <application> element is visible. If the theme property is not set, the default system theme is used.



22.android:windowsoftinputmode


This property represents how the main window of an activity interacts with a window that contains 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 window. Whether the window 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 portion of the window is covered by a soft keyboard.


This property is either a value from the following table, or the state ... Values and adjust ... A combination of values. If it is a combination of multiple values, it is separated using (|), for example


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


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


The soft keyboard is visible when the user chooses activity
value description
stateunspecified does not have the state of the specified soft keyboard (whether hidden or visible). The system chooses a suitable state or depends on the definition in the subject to set. This is the default setting for soft keyboard behavior.
stateunchanged Soft keyboard remains in whatever state it last exists
statehidden
statealwayshidden The soft keyboard is always hidden when activity has input focus, such as when the edit box gets focus.
statevisible The soft keyboard is visible when the user enters the activity's main window
Statealwaysvisi ble        soft keyboard visible when user selects activity
adjustunspecified A Ctivity The main window resizes to make room for the soft keyboard
adjustresize Activity's main window is always adjusted to make room for the soft keyboard on the screen
Adjustpan Activity's main window will not be resized to make room for a soft keyboard on the screen

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android Inventory file details (vi)----<activity> Node properties

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.