Android configuration file (6) and android configuration file

Source: Internet
Author: User

Android configuration file (6) and android configuration file
1. android: allowTaskReparenting


Android: allowTaskReparenting is a task adjustment attribute, which indicates that when the task is re-sent to the foreground, whether the Activity defined by the application can be transferred from the started task to a task with the same affinity.


I have read the previous blog and I know that I have explained this attribute. Why should I mention it again? Because it overlaps with the android: allowTaskReparenting attribute of <application>, when this attribute is provided for the Activity being configured, its default value comes from the <application> node. If this attribute is not configured on the <application> node, false is its default value.


Generally, 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 activities in a task, which are arranged in a certain order. We can use this attribute to force it to refresh to the top-level Activity of the task. When the current task is no longer displayed, that is, when the task associated with this Activity is not displayed on the foreground, you can use this feature to force the Activity to be transferred to a task with the same affinity (task defined by the taskAffinity attribute. A typical usage is to move the Activity of one application to the director of another application.


For example, if a text message (MMS application) contains a phone number, you can click the phone number to start the dialing shortcut interface. However, this dial-up interface is an Activity of the Contact application. In this scenario, it may be an Activity in the task started by the MMS application and located at the top layer of the task. If it is located again in the contact's task, this dial-up interface will not be visible when we restart the text message task.


The affinity of an Activity is defined by the taskAffinity attribute. the affinity of a Task is determined by the affinity of the Root Activity of the current Task. Therefore, according to the definition, the root Activity is always in the same affinity task. Some Activity startup modes (defined by the launchModel attribute) are singleTask and singleInstance, which can only be at the bottom of a task, to use the allowTaskReparenting attribute to adjust the task to which the Activity belongs, the default start mode is limited to the "standard" and "singleTop" modes.



2. android: alwaysRetainTaskState


This attribute indicates whether the status of the task where the Activity is located is saved by the system. If yes, the value is true. If it is set to false, android starts the task in the Initial State under certain circumstances. The default value of this attribute is false. Note that this attribute only applies to the root Activity of the task, and all other activities are ignored.


When you re-select to display the task, the system usually cleans up other activities except the root Activity in the task. In this case, the user does not perform operations on the task within a certain period of time, for example, 30 minutes. If this attribute is set to true, the system displays the task in the final State regardless of how the user returns it.



3. android: clearTaskOnLaunch


This attribute indicates whether all other activities except the root Activity in the task will be removed from the task. If you want to retain only the root Activity at startup, set the value of this attribute to true; otherwise, set it to false. The default value of this attribute is false. This attribute only makes sense for the root Activity that starts a new task. When this parameter is set to true, when the user starts the task again, the request is always processed by the root Activity of the task.


If both this attribute and allowTaskReparenting are true, any Activity that can be reactivated as a parent task will be moved to a task with the same affinity, and the retained Activity will be destroyed.



4. android: configChanges


When some device configurations (such as the screen direction, font size, and network type) change, the Activity will be restarted to adapt to the new configurations. This is a system action. Android also provides an application with a means to prevent such behavior. If you do not want to restart the Activity due to a configuration change, you can configure this attribute and select the configuration you want to block. If you have completed the configuration and selected the configuration you are interested in, the Activity will not restart when these configuration changes, but will notify the application of these configuration changes through the onConfigurationChanged () callback method.


Note: Avoid using this attribute unless necessary.


The following table lists the valid values of this attribute. To set multiple values, separate them with "|.


Value Description
Mcc IMSI mobile country code change-the MCC information in SIM is updated
Mnc IMSI mobile network code-sim mnc information updated
Locale The language environment has changed ---- the user selects a new language through the setting function, and the touch screen changes.
Touchscreen Touch screen changed
Keyboard The keyboard type has changed ---- for example, the user accesses an external keyboard
KeyboardHidden Keyboard visibility has changed
ScreenLayout Screen layout changed
FontScale The font scaling factor has changed ----- the user selects a new font size by setting the module
UiMode The user interface mode has changed-when the user places the device on the base, or when the night mode changes, the user interface changes.
Orientation The screen direction has changed ---- the user flipped the device
Note: If the application is located at API Level13 or higher, the screenSize configuration should also be declared because it will change when the device switches between the horizontal and vertical directions.
ScreenSize The current available screen size has changed, which indicates a change in the current available size. The aspect ratio. This also happens when you switch between the horizontal and vertical directions. However, if the application is positioned at API Level12 or lower, the Activity will always process the configuration by itself.
SmallestScreenSize The physical screen size has changed. This indicates that the size changes, regardless of the direction, only when the actual physical screen size changes (such as conversion to external display. The modification of this configuration responds to a change in the smallestWidth configuration. However, if the application is located at API Level12 or lower, the Activity will automatically modify the configuration.



All these configuration changes can affect the application's selection of resource files. Therefore, when onConfigurationChanged () is called, you usually need to obtain all the resources (including view la S and images) to handle these changes correctly.


Note that if onConfigurationChanged () callback is not implemented, the Activity will be destroyed and re-created.



5. android: enabled


In general, each Activity is instantiated by the Activity framework, but you can configure this attribute to restrict such behaviors of the system. This attribute indicates whether the Activity can be instantiated. If it is set to true, the Activity is instantiated by the system. Otherwise, the Activity is set to false. The default value of this attribute is true. This step is required for every Activity subclass to be instantiated before it is run for the first time. We can use this property to control the behavior of the Android framework instantiating the Activity, but this is risky, so we do not recommend that you do this.



6. android: excludeFromRecents


The Android framework maintains a list of applications named "recently run" to facilitate application switching. This attribute indicates whether the application should exclude the Activity from the list of recently run applications. If this attribute is excluded, the value is true; otherwise, the value is false. The default value of this attribute is false. The premise of this attribute is that the Activity is the root Activity of a task.



7. android: exported


This attribute indicates whether the Activity can be started by components in other applications. If yes, the value is true; otherwise, the value is false. If the value is false, the Activity can only be started by components of the same application or applications with the same user ID.


It is worth noting that if you try to start other application components from your application without using this attribute, you must start it as a new task.



8. android: finishOnTaskLaunch


This attribute indicates whether or not to destroy (or terminate) the instance of the Activity when the user starts the Activity task again (select the task on the home page, if it should be destroyed, the value is true; otherwise, the value is false. the default value of this attribute is false.



9. android: hardwareAccelerated


This attribute indicates whether hardware acceleration should be enabled for the Activity. If it is enabled, this attribute is true; otherwise, it is false. The default value is false.


Note: not all OpenGL 2D operations are accelerated. If you enable the hardware accelerator Renderer, test your application so that it can use the Renderer without generating errors.



10. android: icon


It represents Activity and icons. When the Activity is displayed, this icon is used to display it to the user. For example, the icon used for the Activity of the sample task or the icon on the desktop.


This attribute must be set to image resource reference. If it is not set, use the icon attribute on the <application> node.



11. android: label


This attribute is used to describe a label of the Activity, which is usually displayed along with the Activity icon.


If this attribute is not set, use the value set by the label attribute on the <application> node.



12. android: launchMode


This attribute describes how the Activity should be started. In an Intent object, there are four modes to work with the Activity sign: standard, singleTop, singleTask, and singleInstance. The default mode is standard.


The following table provides two types of modes: standard and singleTop, and singleTask and singleInstance. Activity with standard and singleTop startup modes can be instantiated multiple times.



Usage Startup Mode Multiple instances? Remarks
Normal start Mode Standard Yes Default value. The system always creates a new instance of the Activity in the target task and places the intent into the instance in sequence.
  SingleTop Conditional If the 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 Startup Mode SingleTask No The system creates the Activity on the root of the new task. If an instance already exists, the system sends the intent to the Activity by calling the onNewIntent () method, which allows you to create a new Activity in the task where the Activity is the root.
  SingleInstance No Like singleTask, except that the system does not start any Activity to the task holding the instance, the Activity is always single and the only member of the task.



On the contrary, in singleTask and singleInstance modes, an Activity can start only one task, which remains at the root of the Activity stack. In addition, the device only saves one instance of the Activity at a time.


The standard and singleTop modes are only different in one aspect. In satndard mode, a new Activity instance is instantiated every time to respond to this Intent. Each instance processes an intent. Similarly, a new instance of the Activity in singleTop mode can also be created to handle a new intent. However, if the target task has an instance of Activity at the top of its stack, the existing Activity instance will be used to process the intent (callback onNewintent () method ), instead of creating a new instance. In other cases, if an existing instance of the Activity in singleTop mode is in the target task rather than the top of the stack, or if it is in the top of the stack rather than the target task, A new instance is created and overwhelmed by the Activity stack.


SingleTask and singleInstance modes also have different startup features. In singleTask mode, Activity allows other activities to be part of its tasks. It is always on the root of its own tasks, but other activities can be started into this task. In singleInstance mode, other activities are not allowed to be part of their tasks. If another Activity is started, the Activity is assigned to different tasks, like FLAG_ACTIVITY_NEW_TASK in intent.



13. android: multiprocess


This attribute indicates whether the Activity instance can run in the application process where the component that starts it. If yes, it is true; otherwise, it is false. The default value is false.



14. android: name


This attribute indicates the Class Name of the Activity. It is a subclass of the Activity, and its attribute value should be a standard Java class name (such as com. example. liyuanjing. ManiActivity ). We can also identify it as the abbreviation of the class. For example, the first letter of the name is a vertex (for example. maniActivity), then it is appended with the package name specified by the <manifest> element, and thus becomes com. example. liyuanjing. maniActivity (assuming the package name is com. example. liyuanjing ). This is completely done by the system. We do not need to care about the details of this process, but this attribute must be configured and the default value is not provided.



15. android: noHistory



This attribute is used to determine whether to delete the Activity from its stack when the user leaves the Activity and is no longer visible on the screen. If yes, it is true. Otherwise, it is false. The default value is false.


True means that the Activity will not leave any trace of history, and it will not keep data for the task in the Activity stack, so the user will not be able to return to the Activity.



16. android: permission


Indicates the permission name. If the caller of startActivity () or startActivityForResult () has not been granted the specified permission, the startup fails.


If this attribute is not set, the permission set for the permission attribute of the <application> element should be applied to the Activity. If neither of these attributes is set, the Activity will not be protected by permissions.



17. android: process



This attribute indicates the name of the process that the Activity runs. Generally, all components of an application run in the default process created for the application. <Application> the process attribute of an element can set a different process for all components, but each component can overwrite the value of this attribute, in this way, the application is deployed among multiple processes.


If the name of the property to be allocated starts with a colon (:), a new process that is private to the application will be created when a new process is required and the Activity is running in the process.



18. android: screenOrientation


This attribute indicates the Activity display direction (such as vertical and horizontal). It is a value that can be any character in the following table.


Value Description
Unspecified Default Value: select the direction based on gravity sensing.
User User's current preferred direction
Behind Same direction as Activity
Landscape Horizontal
Portrait Vertical
ReverseLandscape Horizontal direction opposite to normal
ReversePortrait Vertical direction opposite to normal
SensorLandscape It can only be horizontal, but it can be determined whether it is normal or reverse Based on gravity sensing.
SensorPortrait It can be vertical, but it can be determined to be normal or reverse Based on gravity sensing.
Sensor The direction is determined by the device direction sensor. The display direction depends on how the user holds the device. When the user switches the device, the direction changes. Some devices do not flip to all four possible directions by default. You can use fullSensor to allow flip to all four directions.
FullSensor The direction is determined by any of the four directions of the device.
Nosensor No Induction Mode





19. android: stateNotNeeded


This attribute indicates whether the Activity can be terminated and whether it can be restarted successfully without being saved. If the Activity can be restarted without being referenced to the previous state, the attribute is true. If the Activity needs to be referenced to the previous state, it is false. The default value is false.


Generally, before closing the Activity temporarily, we need to call the onSaveInstanceState () method to save the status of the current Activity. This method stores the current status of the Activity in the Bundle object. When the Activity is restarted, the object will be passed to the onCreate () method as a parameter. If this attribute is set to true, onSaveInstanceState () will not be called, and onCreate () will be passed null, which is the same as what the Activity did at the first startup.



20. android: taskAffinity


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



21. android: theme


This attribute refers to the reference that defines an overall theme style resource for the Activity. The so-called style includes the font type and overall style. This attribute makes our Activity more unified and beautiful as a whole.


If this attribute is not set, Activity inherits the theme attribute set by the application as a whole. For details, see the theme attribute of the <application> element. If the theme attribute is not set, the default system topic is used.



22. android: windowSoftInputMode


This attribute indicates how the main window of an Activity interacts with a window containing the on-screen keyboard. Setting this attribute will affect two things.


① Soft keyboard status. Whether to hide the keyboard when the Activity gets the input focus.


② Adjust the main Activity window. Whether the window is adjusted to make room for the keyboard, or whether its content is moved so that the current focus is visible when some windows are covered by the keyboard.


This attribute is either a value in the following table, or a combination of state... and adjust... values. If it is a combination of multiple values, use (|) to separate them, for example


<Activity android: windowSoftInputMode = "stateVisible | adjustResize" ......>


The value set here (stateVisible and adjustResize) overwrites the value set in the topic.


Value Description
StateUnspecified No specified keypad (hidden or visible) status. The system selects an appropriate state or a definition in the dependent topic to set. This is the default setting for the behavior of the soft keyboard.
StateUnchanged The keypad remains in any State of its last existence.
StateHidden When you select Activity, the keyboard is visible.
StateAlwaysHidden When the Activity has an input focus (for example, when the edit box obtains the focus), the keyboard is always hidden.
StateVisible When you enter the main Activity window, the keyboard is visible.
StateAlwaysVisible When you select Activity, the keyboard is visible
AdjustUnspecified Whether to adjust the size of the Main Window of the Activity to free up space for the keyboard
AdjustResize The main window of the Activity is always adjusted to make room for the keyboard on the screen.
AdjustPan The main window of the Activity is not adjusted to the keyboard on the screen to free up space.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.