Activity属性官方详解


<activity>

SYNTAX:
<activity android:allowTaskReparenting=["true" | "false"]
          android:alwaysRetainTaskState=["true" | "false"]
          android:clearTaskOnLaunch=["true" | "false"]
          android:configChanges=["mcc", "mnc", "locale",
                                 "touchscreen", "keyboard", "keyboardHidden",
                                 "navigation", "screenLayout", "fontScale", "uiMode",
                                 "orientation", "screenSize", "smallestScreenSize"]
          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:multiprocess=["true" | "false"]
          android:name="string"
          android:noHistory=["true" | "false"]  
          android:parentActivityName="string" 
          android:permission="string"
          android:process="string"
          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: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. 
决定当另一个和本activity具有相同affinity的activity启动时,本activity是否可以从当前task移动到新activity所在的task中——“true”代表可以从当前task移动到新打开的task,"false"表示此activity必须保持在当前task中不能变动。
 
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".
如果没有设置这个属性,那么他的值将会跟随application中笨属性的设置,如果application中也没有设置,那么默认值为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.
通常一个activity被启动时,这个activity会保持在打开它的task中,并再次完成其生命周期。你可以使用这个属性,在当前task不在显示时,把你的activity绑定到另一个具有相同affinity的task中。通常,这个属性被用来触发一个应用程序的activities移动到另一个应用的主任务中。
 
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.
例如一个e-mail应用中的一条信息包含了一个url链接用来转到一个网页,点击链接会打开一个activity来显示这个页面。显示页面的activity是由另外一个浏览器应用提供的,但这个浏览器的activity此时应该被当成e-mail应用的一个子activity。如果将浏览器提供的activity重新绑定(reparented)到email应用中,那么当用户退出网页时就能继续回到email中了。
 
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.)
activity的affinity属性通过taskAffinity属性定义。一个task的affinity通过此task的根activity的affinity来决定。因此,通过定义affinity属性,根activity将始终存在于他们的task中。由于带有“singleTask”和“singInstance”属性的activities只能存在一个task的栈底,所以重新绑定(reparented)只对于启动模式为"standard"或"singleTop"的activity有效
 
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.
决定当前task中的activity是否始终被系统保持——“true”代表会,“false”代表允许系统将此task设定为最初的状态。默认值为false,这个属性仅对根activity有效,其他activity如果设定了这个属性也将被忽视。
 
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.
通常在一些情况下系统将清除一个task(清除根activity以上的所有activity),例如当用户从主页面中重现选择了这个task。或者用户长时间没有访问过这个task,例如30分钟后回到这个任务。
 
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.
不过如果把这个属性设定为true,用户将总能返回这个task的最后状态,不管他们是如何再次访问这个task的。这很常用,比如一个浏览器应用,用户不希望在再次访问后丢失它的状态(比如用户已经打开了许多标签等等)
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.
设置每当用户从主屏幕再次进入应用时,程序是否清除task中除根activity外的所有activitys——“true”代表始终清除其他的activity,反之为“false”。默认值为false。这个属性只对于根activity有意义,其他的activity如果设置了这个属性也将被忽略。
 
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 or Home 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.
如果这个属性被设置成了true,那么每次用户再次开启task时,都将显示根activity,无论用户之前做了什么操作,也无论他们是使用home键或使用back键退出的应用都会如此。如果这个属性被设置成了false,那当用户再次进入时也有可能会返回根activity(参考上面一个属性android:alwaysRetainTaskState中的说明),但不会总是返回根activity。
 
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  Home and the task went to the background. So the user sees only P when returning to the task.
假设,当从主屏幕运行了activity P,再从P中进入了activity Q。之后按下home键返回主屏幕,然后再点击程序打开activity P。正常情况下用户将会看到Q,因为P和Q在同一个task中,而且当前task顶为Q。但是如果我们给P设置这个属性为true。用户重复上面的这个操作将会看到P,此时Q将会被销毁。
 
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.
如果这个属性和allowTaskReparenting属性同时被设为true。那么带有affinity属性的activity将被重新绑定到其合适的stak中,而其他的activity将会被销毁。
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.
属性列举了当configuration改变时activity是否保存自己的状态。当应用允许时发生了configuration改变,默认情况下activity将关闭并重启自身,但是如果定义了这个属性,activity将不必重启,它将保持运行状态同时调用onConfigurationChanged()方法告知应用。
 

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.

请避免使用这个属性,把其当成最后的处理方式。请阅读Handling Runtime Changes来获得更多的信息,它描述了如何正确地处理由于configuration改变导致程序重启。
Any or all of the following strings are valid values for this attribute. Multiple values are separated by ' |' — for example, " locale|navigation|orientation".
以下字段表示了这个属性的可用值,当程序使用多个值时可用使用“|”来分割。例如 "locale|navigation|orientation"
 
ValueDescription
"mcc" The IMSI mobile country code (MCC) has changed — a SIM has been detected and updated the MCC.
检测到MCC改变时调用——例如SIM卡被系统检测到后将更新MCC
"mnc" The IMSI mobile network code (MNC) has changed — a SIM has been detected and updated the MNC.
IMSI网络状态发送改变时调用——同上
"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.
用户界面发生改变——这可能发生在用户把它的设备插入底座(dock)或者切换到了夜间模式。查看 API level8 计入的 UiModeManager
"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  targetSdkVersion attributes), then you should also declare the  "screenSize" configuration, because it also changes when a device switches between portrait and landscape orientations.
如果你的程序的最低API支持13或以上,你也可以通过设定screenSize值来检测改变,因为当系统发生横竖屏改变时,屏幕分辨率也会发生变化
"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).
当前屏幕的分辨率被改变时——这代表当横纵比发生改变时会触发这种状态,所以当用户切换横竖屏时也会触发这个值。当程序的api被设定在12或者以下时,activity会默认配置这个值(也就是说activity并不会重启,即使是运行在Android 3.2或者以上的设备中时)

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 thesmallestWidth 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).
当屏幕的物理尺寸改变时会触发这个值。它代表的是实际屏幕的改变,不包括当前屏幕的方向(横竖屏),所以这个属性只发生在物理屏幕被改变时,例如用户插入了一个外接屏幕。这个属性的改变实际相对应的是smallestWidth configuration.不过如果当程序的api被设定在12或者以下时,activity会默认配置这个值(也就是说activity并不会重启,即使是运行在Android 3.2或者以上的设备中时)

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.
当布局方向发生改变时,例如从LTR模式切换为RTL模式。
 
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.
所有的configuration改变将影响程序中的resource值。因此,当 onConfigurationChanged() 被调用时,一般情况下需要重新去配置所有资源(包括布局,drawable等等)。
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 ".
确定activity是否可以被程序初始化——“true”代表可以,“false”代表不行,默认值为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.
application节点也有的enabled属性,如果需要设定activity的enabled为true,那么application的enabled也必须被设定为true(他们默认都是true)。如果有一个不为true那么activity将不会被系统实例化
android:excludeFromRecents
Whether or not the task initiated by this activity should be excluded from the list of recently used applications ("recent apps"). 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".

 

设定当前activity是否可以从用户的最近应用列表(“recent app”)中看到。换句话说,如果activity是应用task的根activity,通过设定这个activity的这个属性,可以让你的程序在最近任务列表中不被显示(也就是说非根activity设定此属性无效)。“true”代表不被显示,“false”代表被显示。默认值为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.
设定程序是否可以被其他应用调用——“true”代表可以,“false”代表不行,如果被设定为了false,那么activity只能被其所在的应用调用,或者如果其他的应用和本应用使用相同的 user ID也可以调用此activity。
 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 ".
这个属性的默认值会根据activity是否包含 intent filters而不同。如果activity不包含任何的intent filters,这代表这个activity只能通过准确的包名和类名来打开。这以为着这个activity是当成应用内部activity来打开的(因为其他的程序并不知道你的包名和类名)。所有在这种情况下默认值为false。反之如果activity存在intent-filters,那么代表这个activity可以被外部调用,其默认值为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  permission attribute).
这个属性是定义其他app是否能调用打开此activity的唯一方式。你可以定义一个权限来限制哪个外部app可以调用这个activity(请参考permission属性)
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".
定义如果程序已经打开,当用户通过主屏幕再次点击app时本程序是否重新加载——“true”代表程序重新加载,反之为“false”,默认值为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.
如果这个属性和allowTaskReparenting属性同时设定为true,这个属性将覆盖allTaskReparenting,activity的affinity属性将被忽略。activity将不会被重新绑定,而是会被销毁。
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".
定义activity是否启用硬件加速——“true”代表打开硬件加速,反之为“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.
从Android3.0开始,可以对应用打开基于OpenGL的硬件加速,这可以提高许多2D绘制的性能。当硬件加速打开后,及时你没有明确地使用framework中的相关库,大部分Canvas, Paint, Xfermode, ColorFilter, Shader, and Camera的运算也将会被加速。这能使得应用的动画,滑动更加平滑,应用整体反应速度也将得到提升。不过由于资源打开了硬件加速,你的应用将消耗更多的内存。
 
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.
注意不是所有的OpenGL 2D运算都会得到加速。如果你打开了硬件加速功能,请测试你的应用是否正确地运行了加速功能。
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).
定义代表activity的icon图标。例如程序启动activity的icon将会在应用列表中显示,icon属性通常伴随着label属性。

 

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).
这个图标必须被设定为一个drawable。如果没有设定,那么它将会跟随application中设定的icon属性。
 
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).
activity的图标——包括在activity设定的或者在application中设定的图标——也将被当成activity所有的intent filters的默认图标(参考 <intent-filter> 的icon属性)
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.
label属性应该是一个string的resource值。为了方便开发,他也可以被直接设定为一个普通字符串。
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:
这描述了activity将以何种运行方式启动。有4种模式结合activity中Intent的flags(FLAG_ACTIVITY_* 常量)来确定activity启动时将会发生何种状态

 

"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_TASKinstruction, in which case a different task is chosen — see the taskAffinity attribute).
正如下面的表格中显示的,这4种模式被分成了两类,“standard”和“singleTop”模式是一种,“singleTask”和“singleInstance”是另外一种。前一重模式的activity可以被实例化多次。他们的实力可以被加入任何一个activity运行栈(task)。正常情况下调用startActivity()方法能把他们加入当前的运行栈(除非Intent包含了FLAG_ACTIVITY_NEW_TASK指令,可以把这个activity加入另一个task——参照taskAffinity属性)
 
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.
相对的,带有“singleTask”和“singleInstance”值的activites只能在新的task中运行,他们将总是保持在task的栈底。此外,系统将只保存这个activity的唯一一个实例——当然也只保存唯一一个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 an  onNewIntent() 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.
"standard"和“singleTop”模式之间只有一点不同:每次当用新的Intent打开一个standard的activity,应用将会实例化一个新的activity类。每一个实例中都保存了一个独立的Intent,同样的,每一个singleTop模式的activity也能被创建并保存一个新的Intent。但是,如果一个task中已经有了一个singleTop的activity实例,并且这个实例目前位于栈顶,那么栈顶的实例将会接收到一个新的intent(在onNewIntent()方法中接收到);也就是说这个activity将不会被再次创建。在其他情况下——比如说,如果一个singleTop的activity已经被创建但是不在栈顶,或者他只是在当前栈的栈顶而不是目标栈的栈顶——此时将会创建一个新的activity实例并会将其加入栈中。(?)
 
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.
"singleTask"和"singleInstance"模式之间也有一点不同:"singleTask"模式将会总是存在于栈底,但是允许其他的activity运行到他所在的task中。"singleInstance"模式不允许自身栈内有其他的activity存在。如果在这个activity打开一个新的activity,那么新的activity将会被加到其他的task中——同intent中设置了FLAG_ACTIVITY_NEW_TASK的效果一样。
 
Use CasesLaunch ModeMultiple 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.
正如以上表格显示的一样,standard是activity的默认模式,适用于大部分的activities。singleTop模式也是一种常见而且实用的启动模式。但是另外两种模式对于大部分应用来说都不适用,因为他们和其他activity之间的相互关系对于用户来说会很陌生而且会使得其和大部分app有所区别。
 
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.
不管你选择什么用的启动模式,请确保测试当按下back键时从其他activity或者从其他task返回activity的可用性
 
For more information on launch modes and their interaction with Intent flags, see the Tasks and Back Stack document.
更多关于启动模式相互关系的内容,请参考 Tasks and Back Stack
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".
定义activity是否可以被运行到那个启动它的进程中——true代表可以,falser代表不能,默认值为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.
正常情况下,一个新的activity实例会被运行在application中定义的进程中,所以所有的activity实例都会被运行在同一个进程里。但是如果这个属性被设置为true,那么activity的实例则可以再多进程中运行,不论在哪运行都允许系统创建他们(只要权限允许),这是几乎从来不必要或者定义的东西。
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.
定义activity的类名,其必须是Activity的子类。
 
Once you publish your application, you should not change this name (unless you've set android:exported="false").
只要你发布了你的app,你就不能改变这个值(除非你设定了tandroid:exported="false"),参考  should not change this name
 
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".
设定当用户从当前activity进入其他activity后,当前activity是否被被结束(会调用其的finish()方法)。“true”代表它将会被关闭,“false”代表其不会被关闭,默认值为false。
 
A value of "为您推荐
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值