<activity>

SYNTAX:
<activity android:allowEmbedded=["true" | "false"]
          android:allowTaskReparenting=["true" | "false"]
          android:alwaysRetainTaskState=["true" | "false"]
          android:autoRemoveFromRecents=["true" | "false"]
          android:banner="drawable resource"
          android:clearTaskOnLaunch=["true" | "false"]
          android:configChanges=["mcc", "mnc", "locale",
                                 "touchscreen", "keyboard", "keyboardHidden",
                                 "navigation", "screenLayout", "fontScale",
                                 "uiMode", "orientation", "screenSize",
                                 "smallestScreenSize"]
          android:documentLaunchMode=["intoExisting" | "always" |
                                  "none" | "never"]
          android:enabled=["true" | "false"]
          android:excludeFromRecents=["true" | "false"]
          android:exported=["true" | "false"]
          android:finishOnTaskLaunch=["true" | "false"]
          android:hardwareAccelerated=["true" | "false"]
          android:icon="drawable resource"
          android:label="string resource"
          android:launchMode=["multiple" | "singleTop" |
                              "singleTask" | "singleInstance"]
          android:maxRecents="integer"
          android:multiprocess=["true" | "false"]
          android:name="string"
          android:noHistory=["true" | "false"]  
          android:parentActivityName="string" 
          android:permission="string"
          android:process="string"
          android:relinquishTaskIdentity=["true" | "false"]
          android:screenOrientation=["unspecified" | "behind" |
                                     "landscape" | "portrait" |
                                     "reverseLandscape" | "reversePortrait" |
                                     "sensorLandscape" | "sensorPortrait" |
                                     "userLandscape" | "userPortrait" |
                                     "sensor" | "fullSensor" | "nosensor" |
                                     "user" | "fullUser" | "locked"]
          android:stateNotNeeded=["true" | "false"]
          android:taskAffinity="string"
          android:theme="resource or theme"
          android:uiOptions=["none" | "splitActionBarWhenNarrow"]
          android:windowSoftInputMode=["stateUnspecified",
                                       "stateUnchanged", "stateHidden",
                                       "stateAlwaysHidden", "stateVisible",
                                       "stateAlwaysVisible", "adjustUnspecified",
                                       "adjustResize", "adjustPan"] >   
    . . .
</activity>
CONTAINED IN:
<application>
CAN CONTAIN:
<intent-filter> 
<meta-data>
DESCRIPTION:
Declares an activity (an  Activity subclass) that implements part of the application's visual user interface. All activities must be represented by  <activity> elements in the manifest file. Any that are not declared there will not be seen by the system and will never be run.
ATTRIBUTES:
android:allowEmbedded
Indicate that the activity can be launched as the embedded child of another activity. Particularly in the case where the child lives in a container such as a Display owned by another activity. For example, activities that are used for Wear custom notifications must declare this so Wear can display the activity in it's context stream, which resides in another process.

The default value of this attribute is false.

android:allowTaskReparenting
Whether or not the activity can move from the task that started it to the task it has an affinity for when that task is next brought to the front — " true" if it can move, and " false" if it must remain with the task where it started.

If this attribute is not set, the value set by the corresponding allowTaskReparenting attribute of the <application> element applies to the activity. The default value is "false".

Normally when an activity is started, it's associated with the task of the activity that started it and it stays there for its entire lifetime. You can use this attribute to force it to be re-parented to the task it has an affinity for when its current task is no longer displayed. Typically, it's used to cause the activities of an application to move to the main task associated with that application.

For example, if an e-mail message contains a link to a web page, clicking the link brings up an activity that can display the page. That activity is defined by the browser application, but is launched as part of the e-mail task. If it's reparented to the browser task, it will be shown when the browser next comes to the front, and will be absent when the e-mail task again comes forward.

The affinity of an activity is defined by the taskAffinity attribute. The affinity of a task is determined by reading the affinity of its root activity. Therefore, by definition, a root activity is always in a task with the same affinity. Since activities with "singleTask" or "singleInstance" launch modes can only be at the root of a task, re-parenting is limited to the "standard" and "singleTop" modes. (See also the launchMode attribute.)

android:alwaysRetainTaskState
Whether or not the state of the task that the activity is in will always be maintained by the system — " true" if it will be, and " false" if the system is allowed to reset the task to its initial state in certain situations. The default value is " false". This attribute is meaningful only for the root activity of a task; it's ignored for all other activities.

Normally, the system clears a task (removes all activities from the stack above the root activity) in certain situations when the user re-selects that task from the home screen. Typically, this is done if the user hasn't visited the task for a certain amount of time, such as 30 minutes.

However, when this attribute is "true", users will always return to the task in its last state, regardless of how they get there. This is useful, for example, in an application like the web browser where there is a lot of state (such as multiple open tabs) that users would not like to lose.

android:autoRemoveFromRecents
Whether or not tasks launched by activities with this attribute remains in the  overview screen until the last activity in the task is completed. If  true, the task is automatically removed from the overview screen. This overrides the caller's use of  FLAG_ACTIVITY_RETAIN_IN_RECENTS. It must be a boolean value, either " true" or " false".
android:banner
drawable resource providing an extended graphical banner for its associated item. Use with the <activity> tag to supply a default banner for a specific activity, or with the  <application> tag to supply a banner for all application activities.

The system uses the banner to represent an app in the Android TV home screen. Since the banner is displayed only in the home screen, it should only be specified by applications with an activity that handles the CATEGORY_LEANBACK_LAUNCHER intent.

This attribute must be set as a reference to a drawable resource containing the image (for example"@drawable/banner"). There is no default banner.

See Banners in the UI Patterns for TV design guide, and Provide a home screen banner in Get Started with TV Apps for more information.

android:clearTaskOnLaunch
Whether or not all activities will be removed from the task, except for the root activity, whenever it is re-launched from the home screen — " true" if the task is always stripped down to its root activity, and " false" if not. The default value is " false". This attribute is meaningful only for activities that start a new task (the root activity); it's ignored for all other activities in the task.

When the value is "true", every time users start the task again, they are brought to its root activity regardless of what they were last doing in the task and regardless of whether they used the Back orHome button to leave it. When the value is "false", the task may be cleared of activities in some situations (see the alwaysRetainTaskState attribute), but not always.

Suppose, for example, that someone launches activity P from the home screen, and from there goes to activity Q. The user next presses Home, and then returns to activity P. Normally, the user would see activity Q, since that is what they were last doing in P's task. However, if P set this flag to "true", all of the activities on top of it (Q in this case) were removed when the user pressed Homeand the task went to the background. So the user sees only P when returning to the task.

If this attribute and allowTaskReparenting are both "true", any activities that can be re-parented are moved to the task they share an affinity with; the remaining activities are then dropped, as described above.

android:configChanges
Lists configuration changes that the activity will handle itself. When a configuration change occurs at runtime, the activity is shut down and restarted by default, but declaring a configuration with this attribute will prevent the activity from being restarted. Instead, the activity remains running and its onConfigurationChanged() method is called.

Note: Using this attribute should be avoided and used only as a last resort. Please read Handling Runtime Changes for more information about how to properly handle a restart due to a configuration change.

Any or all of the following strings are valid values for this attribute. Multiple values are separated by '|' — for example, "locale|navigation|orientation".

Value Description
"mcc" The IMSI mobile country code (MCC) has changed — a SIM has been detected and updated the MCC.
"mnc" The IMSI mobile network code (MNC) has changed — a SIM has been detected and updated the MNC.
"locale" The locale has changed — the user has selected a new language that text should be displayed in.
"touchscreen" The touchscreen has changed. (This should never normally happen.)
"keyboard" The keyboard type has changed — for example, the user has plugged in an external keyboard.
"keyboardHidden" The keyboard accessibility has changed — for example, the user has revealed the hardware keyboard.
"navigation" The navigation type (trackball/dpad) has changed. (This should never normally happen.)
"screenLayout" The screen layout has changed — this might be caused by a different display being activated.
"fontScale" The font scaling factor has changed — the user has selected a new global font size.
"uiMode" The user interface mode has changed — this can be caused when the user places the device into a desk/car dock or when the night mode changes. See UiModeManagerAdded in API level 8.
"orientation" The screen orientation has changed — the user has rotated the device.

Note: If your application targets API level 13 or higher (as declared by the minSdkVersion and targetSdkVersionattributes), then you should also declare the "screenSize"configuration, because it also changes when a device switches between portrait and landscape orientations.

"screenSize" The current available screen size has changed. This represents a change in the currently available size, relative to the current aspect ratio, so will change when the user switches between landscape and portrait. However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).

Added in API level 13.

"smallestScreenSize" The physical screen size has changed. This represents a change in size regardless of orientation, so will only change when the actual physical screen size has changed such as switching to an external display. A change to this configuration corresponds to a change in the smallestWidth configuration. However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).

Added in API level 13.

"layoutDirection" The layout direction has changed. For example, changing from left-to-right (LTR) to right-to-left (RTL). Added in API level 17.

All of these configuration changes can impact the resource values seen by the application. Therefore, when onConfigurationChanged() is called, it will generally be necessary to again retrieve all resources (including view layouts, drawables, and so on) to correctly handle the change.

android:documentLaunchMode
Specifies how a new instance of an activity should be added to a task each time it is launched. This attribute permits the user to have multiple documents from the same application appear in the overview screen.

This attribute has four values which produce the following effects when the user opens a document with the application:

Value Description
"intoExisting" The activity reuses the existing task for the document. Using this value is the same as setting the FLAG_ACTIVITY_NEW_DOCUMENT flag, withoutsetting the FLAG_ACTIVITY_MULTIPLE_TASK flag, as described in Using the Intent flag to add a task .
"always" The activity creates a new task for the document, even if the document is already opened. This is the same as setting both theFLAG_ACTIVITY_NEW_DOCUMENT and FLAG_ACTIVITY_MULTIPLE_TASKflags.
"none" The activity does not create a new task for the activity. This is the default value, which creates a new task only when FLAG_ACTIVITY_NEW_TASK is set. The overview screen treats the activity as it would by default: it displays a single task for the app, which resumes from whatever activity the user last invoked.
"never" This activity is not launched into a new document even if the Intent contains FLAG_ACTIVITY_NEW_DOCUMENT. Setting this overrides the behavior of the FLAG_ACTIVITY_NEW_DOCUMENT andFLAG_ACTIVITY_MULTIPLE_TASK flags, if either of these are set in the activity, and the overview screen displays a single task for the app, which resumes from whatever activity the user last invoked.

Note: For values other than "none" and "never" the activity must be defined withlaunchMode="standard". If this attribute is not specified, documentLaunchMode="none" is used.

android:enabled
Whether or not the activity can be instantiated by the system —  "true" if it can be, and " false" if not. The default value is " true".

The <application> element has its own enabled attribute that applies to all application components, including activities. The <application> and <activity> attributes must both be "true" (as they both are by default) for the system to be able to instantiate the activity. If either is "false", it cannot be instantiated.

android:excludeFromRecents
Whether or not the task initiated by this activity should be excluded from the list of recently used applications, the  overview screen. That is, when this activity is the root activity of a new task, this attribute determines whether the task should not appear in the list of recent apps. Set " true" if the task should be  excluded from the list; set " false" if it should be  included. The default value is " false".

android:exported
Whether or not the activity can be launched by components of other applications — " true" if it can be, and " false" if not. If " false", the activity can be launched only by components of the same application or applications with the same user ID.

The default value depends on whether the activity contains intent filters. The absence of any filters means that the activity can be invoked only by specifying its exact class name. This implies that the activity is intended only for application-internal use (since others would not know the class name). So in this case, the default value is "false". On the other hand, the presence of at least one filter implies that the activity is intended for external use, so the default value is "true".

This attribute is not the only way to limit an activity's exposure to other applications. You can also use a permission to limit the external entities that can invoke the activity (see the permissionattribute).

android:finishOnTaskLaunch
Whether or not an existing instance of the activity should be shut down (finished) whenever the user again launches its task (chooses the task on the home screen) — " true" if it should be shut down, and " false" if not. The default value is " false".

If this attribute and allowTaskReparenting are both "true", this attribute trumps the other. The affinity of the activity is ignored. The activity is not re-parented, but destroyed.

android:hardwareAccelerated
Whether or not hardware-accelerated rendering should be enabled for this Activity — " true" if it should be enabled, and " false" if not. The default value is " false".

Starting from Android 3.0, a hardware-accelerated OpenGL renderer is available to applications, to improve performance for many common 2D graphics operations. When the hardware-accelerated renderer is enabled, most operations in Canvas, Paint, Xfermode, ColorFilter, Shader, and Camera are accelerated. This results in smoother animations, smoother scrolling, and improved responsiveness overall, even for applications that do not explicitly make use the framework's OpenGL libraries. Because of the increased resources required to enable hardware acceleration, your app will consume more RAM.

Note that not all of the OpenGL 2D operations are accelerated. If you enable the hardware-accelerated renderer, test your application to ensure that it can make use of the renderer without errors.

android:icon
An icon representing the activity. The icon is displayed to users when a representation of the activity is required on-screen. For example, icons for activities that initiate tasks are displayed in the launcher window. The icon is often accompanied by a label (see the  android:label attribute).

This attribute must be set as a reference to a drawable resource containing the image definition. If it is not set, the icon specified for the application as a whole is used instead (see the <application>element's icon attribute).

The activity's icon — whether set here or by the <application> element — is also the default icon for all the activity's intent filters (see the <intent-filter> element's icon attribute).

android:label
A user-readable label for the activity. The label is displayed on-screen when the activity must be represented to the user. It's often displayed along with the activity icon.

If this attribute is not set, the label set for the application as a whole is used instead (see the<application> element's label attribute).

The activity's label — whether set here or by the <application> element — is also the default label for all the activity's intent filters (see the <intent-filter> element's label attribute).

The label should be set as a reference to a string resource, so that it can be localized like other strings in the user interface. However, as a convenience while you're developing the application, it can also be set as a raw string.

android:launchMode
An instruction on how the activity should be launched. There are four modes that work in conjunction with activity flags ( FLAG_ACTIVITY_* constants) in  Intent objects to determine what should happen when the activity is called upon to handle an intent. They are:

"standard
"singleTop
"singleTask
"singleInstance"

The default mode is "standard".

As shown in the table below, the modes fall into two main groups, with "standard" and "singleTop" activities on one side, and "singleTask" and "singleInstance" activities on the other. An activity with the "standard" or "singleTop" launch mode can be instantiated multiple times. The instances can belong to any task and can be located anywhere in the activity stack. Typically, they're launched into the task that called startActivity() (unless the Intent object contains a FLAG_ACTIVITY_NEW_TASK instruction, in which case a different task is chosen — see the taskAffinity attribute).

In contrast, "singleTask" and "singleInstance" activities can only begin a task. They are always at the root of the activity stack. Moreover, the device can hold only one instance of the activity at a time — only one such task.

The "standard" and "singleTop" modes differ from each other in just one respect: Every time there's a new intent for a "standard" activity, a new instance of the class is created to respond to that intent. Each instance handles a single intent. Similarly, a new instance of a "singleTop" activity may also be created to handle a new intent. However, if the target task already has an existing instance of the activity at the top of its stack, that instance will receive the new intent (in anonNewIntent() call); a new instance is not created. In other circumstances — for example, if an existing instance of the "singleTop" activity is in the target task, but not at the top of the stack, or if it's at the top of a stack, but not in the target task — a new instance would be created and pushed on the stack.

Similarly, if you navigate up to an activity on the current stack, the behavior is determined by the parent activity's launch mode. If the parent activity has launch mode singleTop (or the up intent contains FLAG_ACTIVITY_CLEAR_TOP), the parent is brought to the top of the stack, and its state is preserved. The navigation intent is received by the parent activity's onNewIntent() method. If the parent activity has launch mode standard (and the up intent does not containFLAG_ACTIVITY_CLEAR_TOP), the current activity and its parent are both popped off the stack, and a new instance of the parent activity is created to receive the navigation intent.

The "singleTask" and "singleInstance" modes also differ from each other in only one respect: A "singleTask" activity allows other activities to be part of its task. It's always at the root of its task, but other activities (necessarily "standard" and "singleTop" activities) can be launched into that task. A "singleInstance" activity, on the other hand, permits no other activities to be part of its task. It's the only activity in the task. If it starts another activity, that activity is assigned to a different task — as if FLAG_ACTIVITY_NEW_TASK was in the intent.

Use Cases Launch Mode Multiple Instances? Comments
Normal launches for most activities "standard" Yes Default. The system always creates a new instance of the activity in the target task and routes the intent to it.
"singleTop" Conditionally If an instance of the activity already exists at the top of the target task, the system routes the intent to that instance through a call to itsonNewIntent() method, rather than creating a new instance of the activity.
Specialized launches
(not recommended for general use)
"singleTask" No The system creates the activity at the root of a new task and routes the intent to it. However, if an instance of the activity already exists, the system routes the intent to existing instance through a call to its onNewIntent() method, rather than creating a new one.
"singleInstance" No Same as "singleTask", except that the system doesn't launch any other activities into the task holding the instance. The activity is always the single and only member of its task.

As shown in the table above, standard is the default mode and is appropriate for most types of activities. SingleTop is also a common and useful launch mode for many types of activities. The other modes — singleTask and singleInstance — are not appropriate for most applications, since they result in an interaction model that is likely to be unfamiliar to users and is very different from most other applications.

Regardless of the launch mode that you choose, make sure to test the usability of the activity during launch and when navigating back to it from other activities and tasks using the Back button.

For more information on launch modes and their interaction with Intent flags, see the Tasks and Back Stack document.

android:maxRecents
The maximum number of tasks rooted at this activity in the  overview screen. When this number of entries is reached, the system removes the least-recently used instance from the overview screen. Valid values are 1 through 50 (25 on low memory devices); zero is invalid. This must be an integer value, such as 50. The default value is 16.
android:multiprocess
Whether an instance of the activity can be launched into the process of the component that started it — " true" if it can be, and " false" if not. The default value is " false".

Normally, a new instance of an activity is launched into the process of the application that defined it, so all instances of the activity run in the same process. However, if this flag is set to "true", instances of the activity can run in multiple processes, allowing the system to create instances wherever they are used (provided permissions allow it), something that is almost never necessary or desirable.

android:name
The name of the class that implements the activity, a subclass of  Activity. The attribute value should be a fully qualified class name (such as, " com.example.project.ExtracurricularActivity"). However, as a shorthand, if the first character of the name is a period (for example, " .ExtracurricularActivity"), it is appended to the package name specified in the  <manifest> element.

Once you publish your application, you should not change this name (unless you've setandroid:exported="false").

There is no default. The name must be specified.

android:noHistory
Whether or not the activity should be removed from the activity stack and finished (its  finish()method called) when the user navigates away from it and it's no longer visible on screen — " true" if it should be finished, and " false" if not. The default value is " false".

A value of "true" means that the activity will not leave a historical trace. It will not remain in the activity stack for the task, so the user will not be able to return to it. In this case,onActivityResult() is never called if you start another activity for a result from this activity.

This attribute was introduced in API Level 3.

android:parentActivityName
The class name of the logical parent of the activity. The name here must match the class name given to the corresponding  <activity> element's  android:name attribute.

The system reads this attribute to determine which activity should be started when the user presses the Up button in the action bar. The system can also use this information to synthesize a back stack of activities with TaskStackBuilder.

To support API levels 4 - 16, you can also declare the parent activity with a <meta-data> element that specifies a value for "android.support.PARENT_ACTIVITY". For example:

<activity
    android:name="com.example.app.ChildActivity"
    android:label="@string/title_child_activity"
    android:parentActivityName="com.example.myfirstapp.MainActivity" >
    <!-- Parent activity meta-data to support API level 4+ -->
    <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value="com.example.app.MainActivity" />
</activity>

For more information about declaring the parent activity to support Up navigation, read Providing Up Navigation.

This attribute was introduced in API Level 16.

android:permission
The name of a permission that clients must have to launch the activity or otherwise get it to respond to an intent. If a caller of  startActivity() or  startActivityForResult() has not been granted the specified permission, its intent will not be delivered to the activity.

If this attribute is not set, the permission set by the <application> element's permissionattribute applies to the activity. If neither attribute is set, the activity is not protected by a permission.

For more information on permissions, see the Permissions section in the introduction and another document, Security and Permissions.

android:process
The name of the process in which the activity should run. Normally, all components of an application run in a default process name created for the application and you do not need to use this attribute. But if necessary, you can override the default process name with this attribute, allowing you to spread your app components across multiple processes.

If the name assigned to this attribute begins with a colon (':'), a new process, private to the application, is created when it's needed and the activity runs in that process. If the process name begins with a lowercase character, the activity will run in a global process of that name, provided that it has permission to do so. This allows components in different applications to share a process, reducing resource usage.

The <application> element's process attribute can set a different default process name for all components.

android:relinquishTaskIdentity
Whether or not the activity relinquishes its task identifiers to an activity above it in the task stack. A task whose root activity has this attribute set to " true" replaces the base Intent with that of the next activity in the task. If the next activity also has this attribute set to " true" then it will yield the base Intent to any activity that it launches in the same task. This continues for each activity until an activity is encountered which has this attribute set to " false". The default value is " false".

This attribute set to "true" also permits the activity's use of theActivityManager.TaskDescription to change labels, colors and icons in the overview screen.

android:screenOrientation
The orientation of the activity's display on the device.

The value can be any one of the following strings:

"unspecified" The default value. The system chooses the orientation. The policy it uses, and therefore the choices made in specific contexts, may differ from device to device.
"behind" The same orientation as the activity that's immediately beneath it in the activity stack.
"landscape" Landscape orientation (the display is wider than it is tall).
"portrait" Portrait orientation (the display is taller than it is wide).
"reverseLandscape" Landscape orientation in the opposite direction from normal landscape. Added in API level 9.
"reversePortrait" Portrait orientation in the opposite direction from normal portrait.Added in API level 9.
"sensorLandscape" Landscape orientation, but can be either normal or reverse landscape based on the device sensor. Added in API level 9.
"sensorPortrait" Portrait orientation, but can be either normal or reverse portrait based on the device sensor. Added in API level 9.
"userLandscape" Landscape orientation, but can be either normal or reverse landscape based on the device sensor and the user's sensor preference. If the user has locked sensor-based rotation, this behaves the same aslandscape, otherwise it behaves the same as sensorLandscape.Added in API level 18.
"userPortrait" Portrait orientation, but can be either normal or reverse portrait based on the device sensor and the user's sensor preference. If the user has locked sensor-based rotation, this behaves the same as portrait, otherwise it behaves the same as sensorPortraitAdded in API level 18.
"sensor" The orientation is determined by the device orientation sensor. The orientation of the display depends on how the user is holding the device; it changes when the user rotates the device. Some devices, though, will not rotate to all four possible orientations, by default. To allow all four orientations, use "fullSensor".
"fullSensor" The orientation is determined by the device orientation sensor for any of the 4 orientations. This is similar to "sensor" except this allows any of the 4 possible screen orientations, regardless of what the device will normally do (for example, some devices won't normally use reverse portrait or reverse landscape, but this enables those). Added in API level 9.
"nosensor" The orientation is determined without reference to a physical orientation sensor. The sensor is ignored, so the display will not rotate based on how the user moves the device. Except for this distinction, the system chooses the orientation using the same policy as for the "unspecified" setting.
"user" The user's current preferred orientation.
"fullUser" If the user has locked sensor-based rotation, this behaves the same as user, otherwise it behaves the same as fullSensor and allows any of the 4 possible screen orientations. Added in API level 18.
"locked" Locks the orientation to its current rotation, whatever that is. Added in API level 18.

Note: When you declare one of the landscape or portrait values, it is considered a hard requirement for the orientation in which the activity runs. As such, the value you declare enables filtering by services such as Google Play so your application is available only to devices that support the orientation required by your activities. For example, if you declare either"landscape""reverseLandscape", or "sensorLandscape", then your application will be available only to devices that support landscape orientation. However, you should also explicitly declare that your application requires either portrait or landscape orientation with the <uses-feature> element. For example, <uses-feature android:name="android.hardware.screen.portrait"/>. This is purely a filtering behavior provided by Google Play (and other services that support it) and the platform itself does not control whether your app can be installed when a device supports only certain orientations.

android:stateNotNeeded
Whether or not the activity can be killed and successfully restarted without having saved its state — " true" if it can be restarted without reference to its previous state, and " false" if its previous state is required. The default value is " false".

Normally, before an activity is temporarily shut down to save resources, itsonSaveInstanceState() method is called. This method stores the current state of the activity in a Bundle object, which is then passed to onCreate() when the activity is restarted. If this attribute is set to "true", onSaveInstanceState() may not be called and onCreate() will be passed null instead of the Bundle — just as it was when the activity started for the first time.

A "true" setting ensures that the activity can be restarted in the absence of retained state. For example, the activity that displays the home screen uses this setting to make sure that it does not get removed if it crashes for some reason.

android:taskAffinity
The task that the activity has an affinity for. Activities with the same affinity conceptually belong to the same task (to the same "application" from the user's perspective). The affinity of a task is determined by the affinity of its root activity.

The affinity determines two things — the task that the activity is re-parented to (see theallowTaskReparenting attribute) and the task that will house the activity when it is launched with the FLAG_ACTIVITY_NEW_TASK flag.

By default, all activities in an application have the same affinity. You can set this attribute to group them differently, and even place activities defined in different applications within the same task. To specify that the activity does not have an affinity for any task, set it to an empty string.

If this attribute is not set, the activity inherits the affinity set for the application (see the<application> element's taskAffinity attribute). The name of the default affinity for an application is the package name set by the <manifest> element.

android:theme
A reference to a style resource defining an overall theme for the activity. This automatically sets the activity's context to use this theme (see  setTheme(), and may also cause "starting" animations prior to the activity being launched (to better match what the activity actually looks like).

If this attribute is not set, the activity inherits the theme set for the application as a whole — from the <application> element's theme attribute. If that attribute is also not set, the default system theme is used. For more information, see the Styles and Themes developer guide.

android:uiOptions
Extra options for an activity's UI.

Must be one of the following values.

Value Description
"none" No extra UI options. This is the default.
"splitActionBarWhenNarrow" Add a bar at the bottom of the screen to display action items in the app bar (also known as the action bar), when constrained for horizontal space (such as when in portrait mode on a handset). Instead of a small number of action items appearing in the app bar at the top of the screen, the app bar is split into the top navigation section and the bottom bar for action items. This ensures a reasonable amount of space is made available not only for the action items, but also for navigation and title elements at the top. Menu items are not split across the two bars; they always appear together.

For more information about the app bar, see the Adding the App Bar training class.

This attribute was added in API level 14.

android:windowSoftInputMode
How the main window of the activity interacts with the window containing the on-screen soft keyboard. The setting for this attribute affects two things:
  • The state of the soft keyboard — whether it is hidden or visible — when the activity becomes the focus of user attention.
  • The adjustment made to the activity's main window — whether it is resized smaller to make room for the soft keyboard or whether its contents pan to make the current focus visible when part of the window is covered by the soft keyboard.

The setting must be one of the values listed in the following table, or a combination of one "state..." value plus one "adjust..." value. Setting multiple values in either group — multiple "state..." values, for example — has undefined results. Individual values are separated by a vertical bar (|). For example:

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

Values set here (other than "stateUnspecified" and "adjustUnspecified") override values set in the theme.

Value Description
"stateUnspecified" The state of the soft keyboard (whether it is hidden or visible) is not specified. The system will choose an appropriate state or rely on the setting in the theme.

This is the default setting for the behavior of the soft keyboard.

"stateUnchanged" The soft keyboard is kept in whatever state it was last in, whether visible or hidden, when the activity comes to the fore.
"stateHidden" The soft keyboard is hidden when the user chooses the activity — that is, when the user affirmatively navigates forward to the activity, rather than backs into it because of leaving another activity.
"stateAlwaysHidden" The soft keyboard is always hidden when the activity's main window has input focus.
"stateVisible" The soft keyboard is visible when that's normally appropriate (when the user is navigating forward to the activity's main window).
"stateAlwaysVisible" The soft keyboard is made visible when the user chooses the activity — that is, when the user affirmatively navigates forward to the activity, rather than backs into it because of leaving another activity.
"adjustUnspecified" It is unspecified whether the activity's main window resizes to make room for the soft keyboard, or whether the contents of the window pan to make the current focus visible on-screen. The system will automatically select one of these modes depending on whether the content of the window has any layout views that can scroll their contents. If there is such a view, the window will be resized, on the assumption that scrolling can make all of the window's contents visible within a smaller area.

This is the default setting for the behavior of the main window.

"adjustResize" The activity's main window is always resized to make room for the soft keyboard on screen.
"adjustPan" The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.

This attribute was introduced in API Level 3.

INTRODUCED IN:
API Level 1 for all attributes except for  noHistory and  windowSoftInputMode, which were added in API Level 3.
SEE ALSO:
<application> 
<activity-alias>



SYNTAX:
<activity android:allowEmbedded=["true" | "false"]
          android:allowTaskReparenting=["true" | "false"]
          android:alwaysRetainTaskState=["true" | "false"]
          android:autoRemoveFromRecents=["true" | "false"]
          android:banner="drawable resource"
          android:clearTaskOnLaunch=["true" | "false"]
          android:configChanges=["mcc", "mnc", "locale",
                                 "touchscreen", "keyboard", "keyboardHidden",
                                 "navigation", "screenLayout", "fontScale",
                                 "uiMode", "orientation", "screenSize",
                                 "smallestScreenSize"]
          android:documentLaunchMode=["intoExisting" | "always" |
                                  "none" | "never"]
          android:enabled=["true" | "false"]
          android:excludeFromRecents=["true" | "false"]
          android:exported=["true" | "false"]
          android:finishOnTaskLaunch=["true" | "false"]
          android:hardwareAccelerated=["true" | "false"]
          android:icon="drawable resource"
          android:label="string resource"
          android:launchMode=["multiple" | "singleTop" |
                              "singleTask" | "singleInstance"]
          android:maxRecents="integer"
          android:multiprocess=["true" | "false"]
          android:name="string"
          android:noHistory=["true" | "false"]  
          android:parentActivityName="string" 
          android:permission="string"
          android:process="string"
          android:relinquishTaskIdentity=["true" | "false"]
          android:screenOrientation=["unspecified" | "behind" |
                                     "landscape" | "portrait" |
                                     "reverseLandscape" | "reversePortrait" |
                                     "sensorLandscape" | "sensorPortrait" |
                                     "userLandscape" | "userPortrait" |
                                     "sensor" | "fullSensor" | "nosensor" |
                                     "user" | "fullUser" | "locked"]
          android:stateNotNeeded=["true" | "false"]
          android:taskAffinity="string"
          android:theme="resource or theme"
          android:uiOptions=["none" | "splitActionBarWhenNarrow"]
          android:windowSoftInputMode=["stateUnspecified",
                                       "stateUnchanged", "stateHidden",
                                       "stateAlwaysHidden", "stateVisible",
                                       "stateAlwaysVisible", "adjustUnspecified",
                                       "adjustResize", "adjustPan"] >   
    . . .
</activity>
CONTAINED IN:
<application>
可以包含:
<意图过滤器> 
<元数据>
描述:
声明的活性(一个 活动实现应用程序的可视化用户界面的一部分的子类)。所有活动必须由代表 <活动>在manifest文件中的元素。任何未声明的存在将不会被系统中可以看出,将永远不会被执行。
属性:
机器人:allowEmbedded
表明该活动可以推出,另一个活动的嵌入式孩子。特别是在孩子生活在一个容器中,如由其他活动所拥有的显示情况。例如,用于磨损自定义通知的活动必须申报本这样穿可以显示活动在它的范围内流,它驻留在另一个进程。

此属性的默认值是假的

机器人:allowTaskReparenting
是否该活动可以从它开始有当该任务被旁边带到前面为具有亲和性的任务的任务移动- “   ”,如果它可以移动,而“   ”,如果它必须保持与任务在那里开始。

如果没有设置该属性,通过相应设置的值 allowTaskReparenting 的属性<应用>元素适用于行为。默认值是“  ”。

通常,当一个活动开始时,它与启动它的活动的任务相关联,并且它保持有在其整个生命周期。您可以使用此属性,迫使它重新向父它时将不再显示其当前任务具有亲和力的任务。通常情况下,它用来使一个应用程序的活动移动到与该应用程序相关联的主要任务。

例如,如果一封邮件包含一个链接到一个网页,点击链接带来了可以显示的页面的活动。该活动是由浏览器应用程序中定义,但在启动的电子邮件任务的一部分。如果它被重设父到浏览器的任务,它会显示在浏览器旁边说到前面,将缺席时,电子邮件任务再次挺身而出。

一个活动的亲和力是由定义 taskAffinity属性。任务的亲和力是通过读取它的根活动的亲和性来确定。因此,根据定义,一个根活动总是与相同的亲和力的任务。自从“活动singleTask ”或“singleInstance ”启动模式只能在一个任务,再为人父母的根仅限于“ 标准 ”和“ singleTop ”模式。(参见launchMode 属性。)

机器人:alwaysRetainTaskState
“ -不论该活性是在任务的状态将总是由系统维持  ”,如果它会,而“   ”,如果系统被允许任务复位到它的初始状态在某些情况下。默认值是“   ”。此属性是只为任务的根系活力有意义的; 它忽略了所有其他活动。

通常情况下,系统会清除任务(从堆栈中删除根系活力上述所有活动)在某些情况下,当用户重新选择从主屏幕上的任务。通常情况下,如果用户没有访问过的任务要一定的时间,例如30分钟这样做。

然而,当这个属性为“  ”,用户将总是返回任务在其最后的状态,无论他们如何到达那里。这是有用的,例如,在用户的Web浏览器,其中有很多国家(如多个打开的选项卡)的应用程序,用户都不会喜欢输。

机器人:autoRemoveFromRecents
通过活动,此属性推出与否任务保留在  总览画面,直到在任务的最后一个活动完成。如果 属实,任务自动从总览画面中删除。这将覆盖调用者的使用  FLAG_ACTIVITY_RETAIN_IN_RECENTS。它必须是一个布尔值,无论是“   ”或“   ”。
机器人:旗帜
一个 绘制资源 提供与其相关的项目扩展的图形化的一面旗帜。与使用  <活动>标签来提供一个默认的旗帜特定活动,或与  <应用程序> 标记为所有应用程序提供活动的一面旗帜。

该系统使用的旗帜,代表在Android的电视主屏幕的应用程序。由于该横幅仅在主屏幕上显示出来,它只能通过与处理的活动应用程序指定 CATEGORY_LEANBACK_LAUNCHER意图。

此属性必须设置为包含图像(例如,绘制资源的引用“@绘制/旗帜”)。没有默认的旗帜。

 横幅为电视设计的指导UI模式,并 提供一个主屏幕的旗帜在获取与电视应用程序启动以获取更多信息。

机器人:clearTaskOnLaunch
是否所有的活动都会从任务中删除,除根系活力,无论是从主屏幕上再次推出- “   ”如果任务总是剥离下来到其根系活力,而“   ”,如果不。默认值是“   ”。此属性仅对启动一个新的任务(根活性)的活动是有意义; 它忽略了任务中的所有其他活动。

当值是“  ”,每当用户再次启动任务,他们被带到其根系活力,无论他们上一次在做任务,无论他们是否使用后退主页按钮离开它。当该值是“  ”时,任务可以在某些情况下,活动(见清零alwaysRetainTaskState属性),但并非总是如此。

举个例子,有人从主屏幕启动的活动P,并从那里进入活动问 ​​:用户下次按下主页,然后返回到活动P.通常情况下,用户将看到活动Q,因为这是他们上次做P中的任务。然而,若P设置这个标志为“ ”时,所有的活动在它(Q在这种情况下)顶除去,当用户按压 主页和任务去了背景。因此用户返回到任务时只能看到P上。

如果该属性与allowTaskReparenting 都是“  ”,任何可以活动重新与父母被移到它们共享具有亲和性的任务; 然后将剩余的活动下降,如上所述。

机器人:configChanges
列出配置更改活动将处理本身。当配置在运行时改变时,该活动被关闭,默认情况下重新启动,但在宣布的配置与此属性将阻止重新启动该活动。相反,该活动仍在运行和 onConfigurationChanged()方法被调用。

注意:使用这个属性应避免与只能作为最后的手段。请阅读处理运行时更改有关如何正确处理重启更多信息由于配置改变。

任何或所有下列字符串是该属性的有效值。多个值之间用“ | ” -例如,“ 区域|网站导航|方向 ”。

描述
“ MCC ” IMSI的移动国家代码(MCC)已经改变 - SIM卡已被检测和更新的MCC。
“ MNC ” IMSI的移动网络代码(MNC)已经改变 - 一个SIM卡已被检测并更新MNC。
“ 语言环境 ” 语言环境已经改变 - 用户选择文本应显示在一个新的语言。
“ 触摸屏 ” 触摸屏已经改变。(这不应该发生正常。)
“ 键盘 ” 键盘类型已经改变 - 例如,用户已在外部键盘堵塞。
“ keyboardHidden ” 键盘辅助改变 - 例如,用户已经表明的硬件键盘。
“ 导航 ” 导航型(轨迹球/ DPAD)发生了变化。(这不应该发生正常。)
“ 屏幕布置 ” 屏幕布局改变 - 这可能是由不同的显示被激活而引起的。
“ fontScale ” 字体缩放系数已改变 - 用户已经选择了一个新的全局字体大小。
“ uiMode ” 用户界面模式发生了变化-当用户把设备插入台/车停靠时或夜间模式的变化这是可以引起的。UiModeManager。 在API级别8
“ 方向 ” 屏幕的方向发生了变化 - 用户旋转设备。

注意:如果您的应用程序面向API级别13或更高版本(由申报的minSdkVersiontargetSdkVersion属性),那么你也应该申报“屏幕尺寸” 的配置,因为它也改变纵向和横向之间在设备的开关。

“ 屏幕大小 ” 当前可用的屏幕大小发生了变化。这代表了目前可用的尺寸,相对于当前纵横比的变化,因此,当用户在横向和纵向之间切换将发生变化。但是,如果你的应用程序面向API级别12或更低,那么你的活动总是处理此配置变化本身(在Android 3.2或更高版本的设备上运行时,此配置更改不会重新启动您的活动,甚至)。

在API级别13。

smallestScreenSize 物理屏幕尺寸发生了变化。这代表了尺寸的变化,无论取向的,因此,当实际物理屏幕尺寸已经改变,例如切换到外部显示将只改变。这种结构的改变对应于一个变化 最小宽度配置但是,如果你的应用程序面向API级别12或更低,那么你的活动总是处理此配置变化本身(在Android 3.2或更高版本的设备上运行时,此配置更改不会重新启动您的活动,甚至)。

在API级别13。

“ 的layoutDirection 布局方向已经改变。例如,更改左到右(LTR)为从右到左(RTL)。在API级别17。

所有的这些配置的变化可以影响由应用程序看到的资源值。因此,当onConfigurationChanged()被调用时,它通常会需要再次检索所有的资源(包括视图的布局,图形等)正确处理的变化。

机器人:documentLaunchMode
指定如何活动的一个新实例应该每次启动时间被添加到一个任务。此属性允许用户从同一应用程序的多个文件出现在 总览画面

它的属性产生当用户打开与应用程序的文档以下效果四个值:

描述
intoExisting 活动重用文档的现有任务。使用此值是相同的设定FLAG_ACTIVITY_NEW_DOCUMENT标志,而不设置FLAG_ACTIVITY_MULTIPLE_TASK标志,具体说明 使用意图标志添加任务 
“ 总是 ” 的活动创建的文档的新的任务,即使文档已打开。这是相同的同时设置FLAG_ACTIVITY_NEW_DOCUMENT 和FLAG_ACTIVITY_MULTIPLE_TASK标志。
“  ” 活动不创建活动的新任务。这是缺省值,这就造成只有当一个新的任务FLAG_ACTIVITY_NEW_TASK设置。总览画面对待活动,因为它会默认为:它显示的应用程序,这无论从任何活动恢复最后调用用户的单个任务。
“ 从来没有 ” 此活动不射入即使意图包含一个新的文档 FLAG_ACTIVITY_NEW_DOCUMENT设置此覆盖的行为FLAG_ACTIVITY_NEW_DOCUMENTFLAG_ACTIVITY_MULTIPLE_TASK标志,如果这些在活动设置,并概述屏幕显示的应用程序,这无论从任何活动恢复最后调用用户的单个任务。

注:对于不是“价值 ”和“ 从不 ”活动必须被定义launchMode =“标准”。如果未指定此属性,documentLaunchMode =“无”使用。

机器人:启用
-无论是否在活动可以由系统实例化  “真”,如果它可以是,以及“   ”,如果没有。缺省值是“  ”。

<应用程序> 元素都有自己的启用 适用于所有应用程序组件,包括活动属性。在 <应用> 和<活动>属性必须都是“ ,以便系统能够实例化活动”(因为它们都是由默认值)。如果任一为“ ”时,它不能被实例化。 

机器人:excludeFromRecents
不管是不是通过这个活动发起的任务应该被排除在最近使用的应用程序,在列表中  一览屏幕。也就是说,当这个活动是一个新任务的根系活力,这个属性决定任务是否不应该出现在最近的应用程序列表。设置“   ”,如果该任务应 排除在名单; 设置“   ”,如果它应该被 纳入。默认值是“   ”。

机器人:出口
是否活性可以通过其他应用程序的组件来启动- “   ”,如果它可以是,以及“   ”,如果没有。如果“   ”,则活性可仅由相同的应用程序或应用程序具有相同的用户ID的部件推出。

默认值取决于活动是否包含意图过滤器。没有任何过滤器意味着活动可通过指定确切的类名称仅调用。这意味着,该活动仅用于应用程序内部使用(因为其他人不知道的类名称)。因此,在这种情况下,默认值是“  ”。另一方面,至少一个过滤器的存在意味着该活动旨在供外部使用,因此缺省值是“  ”。

此属性是不限制活动接触到其他应用程序的唯一途径。还可以使用权限来限制可以调用该活动的外部实体(见 许可 属性)。

机器人:finishOnTaskLaunch
不管是不是活动的现有实例,应关闭(完)每当用户再次启动它的任务(选择任务在主屏幕上) - “  ”,如果它应该关闭,而“   ”如果不是。默认值是“   ”。

如果该属性与 allowTaskReparenting 都是“  ”,该属性胜过另一个。该活动的亲和力被忽略。该活性不重新父,而破坏。

机器人:hardwareAccelerated
“ -不管是不是硬件加速渲染应该为此活动启用 真正 ”是否应该被启用,而“   ”如果不是。默认值是“  ”。

从Android 3.0的开始,一个硬件加速的OpenGL渲染是提供给应用程序,以提高许多常见的2D图形操作的性能。当启用硬件加速渲染器,在帆布,油漆,Xfermode,ColorFilter,Shader和照相机的大部分操作都加速。这将导致更加平滑的动画,更流畅滚动,并整体提高了响应,即使应用程序没有明确使用该框架的OpenGL库。由于启用硬件加速所需增加的资源,你的应用程序会消耗更多的内存。

注意,并非所有的OpenGL的2D操作的加速。如果启用硬件加速渲染器,测试应用程序,以确保它可以利用渲染没有错误。

安卓图标
表示活动的图标。当需要在屏幕上活动的表示的图标会显示给用户。例如,对于启动任务的活动图标显示在发射窗口。该图标常伴有标签(见 机器人:标签属性)。

此属性必须设置为包含图像定义的可绘制资源的引用。如果没有设置,对作为一个整体来代替应用程序指定的图标(参见 <应用程序> 元素的图标属性)。

活动的图标-无论在这里还是由设置 <应用> 元素-也是所有活动的意图过滤器的默认图标(见 <意图过滤器>元素的 图标属性)。

机器人:标签
为活动的用户可读的标签。该标签显示在屏幕上活动时必须表示给用户。它通常与活动图标一起显示。

如果没有设置该属性,作为一个整体来代替应用程序的标签集(见<应用程序>元素的 标签属性)。

活动的标签-无论在这里还是由设置 <应用>元素-也是所有活动的意图过滤器默认标签(见 <意图过滤器>元素的 标签属性)。

标签应设置为一个字符串资源的引用,以便它可以被本地化一样在用户界面的其他串。但是,作为一种方便,而你开发的应用程序,它也可以被设置为一个原始字符串。

机器人:launchMode
上的活动应该如何启动的指令。有迹象表明,在活动标志(协同工作,四种模式 FLAG_ACTIVITY_ *常量) 意向对象,以确定何时活动被要求处理的意图应该发生什么。他们是:

“ 标准 ” 
“ singleTop ” 
“ singleTask ” 
“ singleInstance ”

默认模式为“ 标准 ”。

如下表所示,模式分为两大组,“ 标准 ”和“ singleTop一侧”的活动,以及“ singleTask ”和“singleInstance在另一”活动。用“的活性标准 ”或“ singleTop ”发射模式可以被实例化多次。实例可以属于任何任务,并可以在活动的堆栈的任何位置。通常情况下,它们发射到调用该任务startActivity() (除非意图对象包含 FLAG_ACTIVITY_NEW_TASK 指令,在这种情况下,选择不同的任务-参见 taskAffinity属性)。

与此相反,“ singleTask ”和“ singleInstance ”活动才能开始的任务。它们总是在活动堆的根。此外,该设备可以一次容纳只有一个活动的实例-只有一个这样的任务。

该“ 标准 ”和“ singleTop ”模式,彼此只是一个方面不同:每当有一个“新的意图标准 ”活动,创建该类的新实例对这一意图做出回应。每个实例处理一个意图。同样地,一“的一个新实例singleTop”活动也可被创建,以处理新的意图。然而,如果目标任务已经在其堆栈的顶部的活性的现有实例,该实例将接收新的意图(在 onNewIntent()调用); 不创建一个新的实例。在其他情况下-例如,如果“的现有实例singleTop ”活动是在目标的任务,而不是在堆栈的顶部,或者如果它是在堆栈的顶部,而不是在所述目标任务-一个新的实例会被创建并压入堆栈。

同样,如果您 浏览了当前栈上的活动,该行为是由父活动的启动模式决定。如果父活动有发射模式singleTop(或向上意图包含FLAG_ACTIVITY_CLEAR_TOP),父被带到堆栈的顶部,并且其状态被保留。导航意图由父活动的接收onNewIntent() 方法。如果父活动有发射模式标准(和 向上意图不包含FLAG_ACTIVITY_CLEAR_TOP),当前活动及其父均弹出堆栈,并且在创建父活动的新实例来接收导航意图。

在“ singleTask ”和“ singleInstance A”:“模式也彼此只在一个方面有所不同singleTask ”活动允许的其他活动是其任务的一部分。它总是在其工作的根本,而其他活动(不一定是“ 标准 ”和“singleTop ”的活动)可以被发射到该任务。A“ singleInstance ”活动,另一方面,允许没有其他活动是其任务的一部分。它在任务的唯一活动。如果它开始另一个活动,该活动被分配到一个不同的任务-仿佛FLAG_ACTIVITY_NEW_TASK在意图。

用例 启动模式 多个实例? 注释
对于大多数正常活动启动 “ 标准 ” 默认。系统总是会在目标任务和路线的意图给它的活动的新实例。
“ singleTop ” 有条件 如果活动的一个实例已经存在于目标任务的顶部,系统路由通过其呼叫的意图,该实例onNewIntent()方法,而不是创建活动的新实例。
专门推出(不推荐用于一般用途)
“ singleTask ” 没有 系统将创建一个新的任务和路线的意图,它的根活动。但是,如果活动的一个实例已经存在,系统路由意图通过其呼叫现有实例onNewIntent()方法,而不是创建一个新的。
singleInstance 没有 同为“ singleTask” ,所不同的是,系统不发射任何其他的活动进保持该实例的任务。活动始终是它的任务单,唯一成员。

如上表中所示,标准是默认模式和适用于大多数类型的活动。SingleTop也是许多类型的活动,一个共同的和有用的发射模式。其它模式- singleTasksingleInstance -是 不适合于大多数的应用,因为它们导致在很可能是不熟悉的用户,是从其他大多数应用中是非常不同的交互模式。

无论您选择的发射方式的,请务必在发射过程中,测试活动的可用性和使用其他的活动和任务导航回 ​​到它的时候后退按钮。

有关启动模式的详细信息和他们的意图旗帜互动,看到 任务和返回堆栈 文件。

机器人:maxRecents
在该此次活动扎根的最大任务数  总览画面。当达到此数量的条目,系统将删除概览屏幕最近最少使用的实例。有效值是1到50(25低内存设备上); 零是无效的。这必须是整数值,例如50。默认值是16。
机器人:多进程
是否活动的一个实例可以被发射到启动它的成分的方法- “   ”,如果它可以是,以及“   ”,如果没有。默认值是“   ”。

通常情况下,一个活动的新实例被发射到该定义它的应用程序的过程中,所以在同一进程中运行的活动的所有实例。但是,如果该标志被设置为“  ”,活动的实例可以在多个进程运行,允许的地方时,它们的系统来创建实例(提供权限允许的话),而这是几乎没有必要或希望的。

安卓:名称
实现活动,子类的类的名称  活动。该属性值应该是一个完全合格的类名(例如,“ com.example.project.ExtracurricularActivity ”)。然而,作为一个速记,如果名称的第一个字符是一个周期(例如,“  .ExtracurricularActivity ”)时,它被附加到在该指定的包名称  <清单>元素。

一旦你发布你的应用程序,你应该不会改变这个名字(除非你设置的android:出口 =“假”)。

没有默认值。必须指定名称。

机器人:noHistory
不管是不是活动应该从活动堆栈被删除,完成(其 完成() 调用的方法),当用户导航远离它,它不再可见屏幕上- “   ”,如果它应该完成,而“   ”如果不。默认值是“   ”。

值“  ”是指该活动不会留下历史痕迹。它不会留在任务的活动栈,因此用户将不能够返回到它。在这种情况下, 的onActivityResult()如果你开始另一项活动,从这一活动的结果不会被调用。

这个属性在API级别3引入的。

机器人:parentActivityName
活动的逻辑父的类名。该名称必须在这里提供给相应的类名匹配 <活动>元素的  名称:Android属性。

系统会读取此属性,以确定哪些活动,当用户按下操作栏中向上按钮应启动。该系统还可以使用此信息来合成与活动的背叠TaskStackBuilder

为了支持API等级4 - 16,你也可以声明与父活动<元 ​​数据>元素指定的值“android.support.PARENT_ACTIVITY” 。例如:

<activity 
    android:name = "com.example.app.ChildActivity" 
    android:label = "@string/title_child_activity" 
    android:parentActivityName = "com.example.myfirstapp.MainActivity"  > 
    <!--父活动的元数据来支持API级别4+ --> 
    <meta-data 
        android:name = "android.support.PARENT_ACTIVITY" 
        android:value = "com.example.app.MainActivity"  /> 
</activity>

有关声明父活动,以支持向上导航的更多信息,请阅读提供高达导航

这个属性在API级别16引入的。

机器人:许可
客户端必须要推出的活动或以其他方式得到它的一个意图做出回应权限的名称。如果主叫方 startActivity()或  startActivityForResult() 没有被授予指定的权限,其意图将不会传递到活动中。

如果没有设置该属性,通过设置权限 <应用程序> 元素的 权限 属性适用于该活动。如果没有属性被设置时,活性不受权限保护。

有关权限的详细信息,请参阅 权限 在引进和其他文档,部分 安全和权限

机器人:过程
该活动应该运行的进程的名称。通常情况下,一个应用程序的所有组件在应用程序中创建一个默认的进程名运行,你并不需要使用此属性。但是,如果有必要,你可以用这个属性覆盖默认的进程名,使您可以在多个流程传播你的应用组件。

(“:”)如果分配给该属性名称以冒号开始,一个新的进程,私有的应用程序,在需要时创建和活动在这一过程中运行。如果进程名称以小写字母开头,该活动将在名字的全局进程中运行,只要它有权这样做。这使得在不同应用程序的组件共享一个过程,减少资源的使用。

<应用程序>元素的 过程 属性可以为所有组件设置不同的默认进程名。

机器人:relinquishTaskIdentity
是否活动放弃其任务标识符在任务堆栈它上面的活性。其根活动任务有这个属性设置为“   ”替换,在任务下一个活动的基地意向。如果接下来的活动也有这个属性设置为“   ”,那么它会生成碱性意图,它在相同的任务启动任何活动。这继续为每个活动,直到活动遇到有此属性设置为“   ”。默认值是“   ”。

该属性设置为“  ”也允许活动的使用的 ActivityManager.TaskDescription改变标签,颜色和图标的总览画面

机器人:screenOrientation
该活动的装置上显示的方向。

的值可以是以下的字符串中的任何一个:

“ 未指定 ” 的默认值。该系统选择的方向。该策略时使用,因此,在具体情况下作出的选择,可以从不同的设备到设备。
“ 背后 ” 相同的方向这立即将其下方在活动堆栈的活性。
“ 景观 ” 横向(显示器宽度大于高)。
“ 画像 ” 纵向(显示器高度大于宽)。
reverseLandscape 在正常横向相反的方向横向的方向。 在API 9级。
reversePortrait 在正常纵向相反的方向纵向。 在API 9级。
sensorLandscape 横向方向,但可以根据设备传感器是正常或反向的风景线。 在API 9级。
“ sensorPortrait 纵向方向,但可以是正常或反向根据设备传感器的画像。 在API 9级。
“ userLandscape ” 横向,但也可以是正常或反向景观基于设备传感器和用户的传感器偏好。如果用户已经锁定基于传感器的旋转,这样的行为一样的风景,否则它的行为一样sensorLandscape。 在API级别18添加。
“ userPortrait ” 纵向,但也可以是正常或基于设备传感器和用户的传感器偏好反转的画像。如果用户已经锁定基于传感器的旋转,这样的行为一样的画像,否则它的行为一样sensorPortrait。 在API级别18添加。
“ 传感器 ” 的取向是由设备取向传感器确定。显示器的取向取决于用户是如何保持装置; 当用户旋转设备它的变化。某些设备,不过,不会转动到所有四个可能的方向,默认情况下。为了让所有的四个方位,用“fullSensor”
“ fullSensor ” 的方向由任何的4方向的装置方位传感器来确定。这类似于“传感器”除了这允许任何4个可能的屏幕方向,无论什么样的设备,通常会做(例如,某些设备将无法正常使用反向纵向或横向反转,而这使那些)。增加在API 9级。
“ nosensor ” 取向不参照的物理方位传感器来确定。该传感器被忽略,所以显示不会转动的基础上如何在用户移动设备。除了 ​​这一区别,系统选择使用相同的策略作为“的方向未指定 ”设定。
“ 用户 ” 用户的当前优选的取向。
“ fullUser ” 如果用户已经锁定基于传感器的旋转,这样的行为一样的用户,否则它的行为一样fullSensor和允许任何4个可能的屏幕方向的。 在API级别18。
“ 锁定 ” 锁定方向,以目前的旋转,无论是。 在API级别18。

注意:当你声明的横向或纵向的一个值,它被认为是该活动运行方向的硬性要求。因此,您声明价值实现按服务过滤,如谷歌播放让你的应用程序只可用于支持你的活动所需的取向装置。例如,如果你声明或者“风景”“reverseLandscape” ,或 “sensorLandscape” ,那么你的应用程序将只提供给支持横向设备。不过,你也应该明确地声明,您的应用需要纵向或横向与<用途特征> 元素。例如,<使用特征的android:NAME =“android.hardware.screen.portrait”/>。这纯粹是由谷歌播放(和支持它的其他服务)及平台本身并不控制是否可以安装你的应用程序时,系统仅支持某些方向提供了一个筛选行为。

机器人:stateNotNeeded
无论是否该活动可以被杀死,并成功地重新启动,而不必保存其状态- “   ”,如果它可以在不参考以前的状态重新启动,而“  ,如果需要其以前的状态。” 默认值是“   ”。

通常情况下,前一个活动被暂时关闭,以节约资源,其 的onSaveInstanceState() 方法被调用。这种方法存储在该活动的当前状态 对象,然后将其传递给 的onCreate()重新启动活动时。如果这个属性被设置为“  ” 的onSaveInstanceState()可能不会调用和的onCreate()将被传递而不是捆绑的-只是因为它是当活动开始的第一次。

A“  ”的设置确保了活动可在不存在保留状态的重新启动。例如,显示在主屏幕的活动使用此设置以确保如果它崩溃出于某种原因,它不会删除。

机器人:taskAffinity
该活动具有用于具有亲和性的任务。具有相同的亲和力活动概念属于相同的任务(从用户的角度来看,同样的“应用程序”)。任务的亲和力是通过它的根活动的亲和性来确定。

的亲和力决定了两件事情-该活性被重新父到任务(见allowTaskReparenting 属性),并且当它与推出,将容纳该活动的任务FLAG_ACTIVITY_NEW_TASK 标志。

默认情况下,在应用程序中的所有活动具有相同的亲和力。您可以设置不同的此属性将它们分组,甚至置于同一任务中不同的应用程序定义的活动。要指定活动没有任何任务的亲和力,将其设置为空字符串。

如果没有设置该属性,该活动将继承亲和力的应用程序设置(见 <应用程序> 元素的 taskAffinity属性)。对于应用程序的默认亲和力的名称是由设置的包名 <清单> 元素。

安卓主题
引用到样式定义资源对活动的总体主题。此自动设置活动的使用本主题上下文(见  setTheme(),并且还可以先于活动而被推出(以更好地匹配什么活动实际上看起来像)会导致“起动”的动画。

如果没有设置该属性,该活动将继承应用程序作为一个整体的主题设置-从 <应用程序> 元素的 主题属性。如果也没有设置该属性,则使用默认的系统主题。欲了解更多信息,请参阅样式和主题开 ​​发人员指南。

机器人:uiOptions
为活动的UI额外的选项。

必须是以下值之一。

描述
“没有” 没有额外的UI选项。这是默认的。
“splitActionBarWhenNarrow” 在屏幕显示的操作项目的底部增加一个栏应用栏(也称为 操作栏),受限于横向空间时(例如,当在纵向模式在手机上)。相反,少数出现在屏幕顶部的应用程序栏行动项目,应用栏分成顶部导航部分和操作项的底部栏。这确保的空间合理量是由不仅可用于该操作的物品,也为在顶部导航和标题元素。菜单项目不跨越两个酒吧分割; 他们总是一起出现。

有关应用栏的详细信息,请参阅添加应用栏培训班。

在API级别14加入这个属性。

机器人:windowSoftInputMode
该活动的主窗口如何用含有屏幕上的软键盘窗口交互。这个属性的设置会影响两件事情:
  • 软键盘的状态 - 无论是隐藏或显示 - 当活动成为用户关注的焦点。
  • 调整该活动的主窗口中进行 - 无论是较小的调整,以腾出空间软键盘,还是它的内容平移,使当前的焦点时可见窗口的部分被软键盘覆盖。

该设置必须是下表中列出的值之一,或一“的组合状态... ”值加一“ 调整...... ”的价值。在任一组设置多个值-多“ 的状态...... ”的价值观,例如-已不确定的结果。(单个值由竖线|)。例如:

<活动 的android:windowSoftInputMode = “stateVisible | adjustResize” 。。。>

值这里设置(不是“ stateUnspecified ”和“ adjustUnspecified在主题设置覆盖值”)。

描述
“ stateUnspecified 未指定的软键盘的状态(它是否隐藏或可见)。该系统将选择一个合适的状态或依赖于主题的设置。

这是软键盘的行为的默认设置。

“ stateUnchanged ” 软键盘保持在上次的,不管状态是否可见或隐藏,当活动就浮出水面。
“ stateHidden ” 当用户选择该活动的软键盘被隐藏 - 也就是说,当用户肯定地导航着的活性,而不是背到它,因为离开另一个活动的。
stateAlwaysHidden 软键盘总是隐藏在活动的主窗口有输入焦点。
“ stateVisible ” 软键盘时可见这是正常合适的(当用户浏览着该活动的主窗口)。
stateAlwaysVisible 也就是说,当用户肯定地导航着的活性,而不是背到它,因为离开另一个活动的 - 当用户选择该活动的软键盘变得可见。
adjustUnspecified 它是不确定的活动的主窗口是否调整大小以腾出空间给软键盘,或平移窗口中的内容是否使当前焦点在屏幕上是可见的。该系统将自动选择取决于窗口的内容是否具有可滚动的内容的任何布局的观点,这些模式中的一种。如果有这样的视图,该窗口将被调整,在该滚动可以使更小的区域内的所有的窗口的内容可见的假设。

这是在主窗口的行为的默认设置。

“ adjustResize ” 活动的主窗口总是被调整,以腾出空间给软键盘在屏幕上。
“ adjustPan ” 不能调整大小活动的主窗口,以腾出空间给软键盘。相反,窗口中的内容会被自动平移,使目前的工作重点是永远不会被键盘遮住,用户可以随时查看自己所键入的内容。这通常比调整大小不太理想的,因为用户可能需要关闭软键盘以获得在与窗口的遮蔽部件相互作用。

这个属性在API级别3引入的。

介绍了:
除了 ​​对所有API级别1属性  noHistory和  windowSoftInputMode,这是在API级别3添加。
也可以看看:
<应用程序> 
<活动别名>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
`<FrameLayout>` 在 AndroidManifest.xml 文件中的 `<application>` 或 `<activity>` 标签内通常是不被期望的。AndroidManifest.xml 是用于描述应用程序元数据的XML文件,它定义了应用的基本信息、组件(如Activity、Service、BroadcastReceiver等)以及权限等。`<FrameLayout>` 是一个布局容器,通常在 XML 布局文件中使用,用于放置其他视图。 遇到 `<FrameLayout>` 在这些位置可能是以下几个原因: 1. 错误的 XML 结构:开发者可能不小心将 FrameLayout 的标签放在了不应该放在这里的地方,比如误将它用作 Activity 的根布局而不是作为内部嵌套的布局组件。 2. 代码生成:有时候,动态添加 View 或者框架层面的代码生成可能会导致 `<FrameLayout>` 不受预期地出现在这里。 3. 动态布局或框架扩展:如果你正在使用某些第三方库或者自定义模块,它们可能在 Manifest 中添加了额外的布局元素。 4. 过期或未使用的组件:如果这是一个以前添加但不再需要的 FrameLayout,可能是忘记移除的旧代码遗留。 为了解决这个问题,你可以采取以下步骤: - 检查你的 XML 文件结构,确保 `<FrameLayout>` 在正确的上下文中使用。 - 如果是动态添加,确认你在正确的时间和地点调用了相应的 API。 - 清理并重新构建项目,看看是否有编译错误或未处理的异常。 - 查看相关代码库的更新日志或文档,确保没有冲突或未兼容的改动。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值