1page.title=<activity> 2parent.title=The AndroidManifest.xml File 3parent.link=manifest-intro.html 4@jd:body 5 6<dl class="xml"> 7<dt>syntax:</dt> 8<dd><pre class="stx"><activity android:<a href="#reparent">allowTaskReparenting</a>=["true" | "false"] 9 android:<a href="#always">alwaysRetainTaskState</a>=["true" | "false"] 10 android:<a href="#clear">clearTaskOnLaunch</a>=["true" | "false"] 11 android:<a href="#config">configChanges</a>=["mcc", "mnc", "locale", 12 "touchscreen", "keyboard", "keyboardHidden", 13 "navigation", "screenLayout", "fontScale", "uiMode", 14 "orientation", "screenSize", "smallestScreenSize"] 15 android:<a href="#enabled">enabled</a>=["true" | "false"] 16 android:<a href="#exclude">excludeFromRecents</a>=["true" | "false"] 17 android:<a href="#exported">exported</a>=["true" | "false"] 18 android:<a href="#finish">finishOnTaskLaunch</a>=["true" | "false"] 19 android:<a href="#hwaccel">hardwareAccelerated</a>=["true" | "false"] 20 android:<a href="#icon">icon</a>="<i>drawable resource</i>" 21 android:<a href="#label">label</a>="<i>string resource</i>" 22 android:<a href="#lmode">launchMode</a>=["multiple" | "singleTop" | 23 "singleTask" | "singleInstance"] 24 android:<a href="#multi">multiprocess</a>=["true" | "false"] 25 android:<a href="#nm">name</a>="<i>string</i>" 26 android:<a href="#nohist">noHistory</a>=["true" | "false"] <!-- ##api level 3## --> 27 android:<a href="#parent">parentActivityName</a>="<i>string</i>" <!-- api level 16 --> 28 android:<a href="#prmsn">permission</a>="<i>string</i>" 29 android:<a href="#proc">process</a>="<i>string</i>" 30 android:<a href="#screen">screenOrientation</a>=["unspecified" | "behind" | 31 "landscape" | "portrait" | 32 "reverseLandscape" | "reversePortrait" | 33 "sensorLandscape" | "sensorPortrait" | 34 "userLandscape" | "userPortrait" | 35 "sensor" | "fullSensor" | "nosensor" | 36 "user" | "fullUser" | "locked"] 37 android:<a href="#state">stateNotNeeded</a>=["true" | "false"] 38 android:<a href="#aff">taskAffinity</a>="<i>string</i>" 39 android:<a href="#theme">theme</a>="<i>resource or theme</i>" 40 android:<a href="#uioptions">uiOptions</a>=["none" | "splitActionBarWhenNarrow"] 41 android:<a href="#wsoft">windowSoftInputMode</a>=["stateUnspecified", 42 "stateUnchanged", "stateHidden", 43 "stateAlwaysHidden", "stateVisible", 44 "stateAlwaysVisible", "adjustUnspecified", 45 "adjustResize", "adjustPan"] > <!-- ##api level 3## --> 46 . . . 47</activity></pre></dd> 48 49<dt>contained in:</dt> 50<dd><code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code></dd> 51 52<dt>can contain:</dt> 53<dd><code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"><intent-filter></a></code> 54<br/><code><a href="{@docRoot}guide/topics/manifest/meta-data-element.html"><meta-data></a></code></dd> 55 56<dt>description:</dt> 57<dd>Declares an activity (an {@link android.app.Activity} subclass) that 58implements part of the application's visual user interface. All activities 59must be represented by {@code <activity>} 60elements in the manifest file. Any that are not declared there will not be seen 61by the system and will never be run. 62 63<dt>attributes:</dt> 64<dd><dl class="attr"> 65<dt><a name="reparent"></a>{@code android:allowTaskReparenting}</dt> 66<dd>Whether or not the activity can move from the task that started it to 67the task it has an affinity for when that task is next brought to the 68front — "{@code true}" if it can move, and "{@code false}" if it 69must remain with the task where it started. 70 71<p> 72If this attribute is not set, the value set by the corresponding 73<code><a href="{@docRoot}guide/topics/manifest/application-element.html#reparent">allowTaskReparenting</a></code> 74attribute of the <code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> element 75applies to the activity. The default value is "{@code false}". 76</p> 77 78<p> 79Normally when an activity is started, it's associated with the task of 80the activity that started it and it stays there for its entire lifetime. 81You can use this attribute to force it to be re-parented to the task it 82has an affinity for when its current task is no longer displayed. 83Typically, it's used to cause the activities of an application to move 84to the main task associated with that application. 85</p> 86 87<p> 88For example, if an e-mail message contains a link to a web page, clicking 89the link brings up an activity that can display the page. That activity 90is defined by the browser application, but is launched as part of the e-mail 91task. If it's reparented to the browser task, it will be shown when the 92browser next comes to the front, and will be absent when the e-mail task 93again comes forward. 94</p> 95 96<p> 97The affinity of an activity is defined by the 98<code><a href="#aff">taskAffinity</a></code> attribute. The affinity 99of a task is determined by reading the affinity of its root activity. 100Therefore, by definition, a root activity is always in a task with the 101same affinity. Since activities with "{@code singleTask}" or 102"{@code singleInstance}" launch modes can only be at the root of a task, 103re-parenting is limited to the "{@code standard}" and "{@code singleTop}" 104modes. (See also the <code><a href="#lmode">launchMode</a></code> 105attribute.) 106</p></dd> 107 108<dt><a name="always"></a>{@code android:alwaysRetainTaskState}</dt> 109<dd>Whether or not the state of the task that the activity is in will always 110be maintained by the system — "{@code true}" if it will be, and 111"{@code false}" if the system is allowed to reset the task to its initial 112state in certain situations. The default value is "{@code false}". This 113attribute is meaningful only for the root activity of a task; it's ignored 114for all other activities. 115 116<p> 117Normally, the system clears a task (removes all activities from the stack 118above the root activity) in certain situations when the user re-selects that 119task from the home screen. Typically, this is done if the user hasn't visited 120the task for a certain amount of time, such as 30 minutes. 121</p> 122 123<p> 124However, when this attribute is "{@code true}", users will always return 125to the task in its last state, regardless of how they get there. This is 126useful, for example, in an application like the web browser where there is 127a lot of state (such as multiple open tabs) that users would not like to lose. 128</p></dd> 129 130<dt><a name="clear"></a>{@code android:clearTaskOnLaunch}</dt> 131<dd>Whether or not all activities will be removed from the task, except for 132the root activity, whenever it is re-launched from the home screen — 133"{@code true}" if the task is always stripped down to its root activity, and 134"{@code false}" if not. The default value is "{@code false}". This attribute 135is meaningful only for activities that start a new task (the root activity); 136it's ignored for all other activities in the task. 137 138<p> 139When the value is "{@code true}", every time users start the task again, they 140are brought to its root activity regardless of what they were last doing in 141the task and regardless of whether they used the <em>Back</em> or <em>Home</em> button to 142leave it. When the value is "{@code false}", the task may be cleared of activities in 143some situations (see the 144<code><a href="#always">alwaysRetainTaskState</a></code> attribute), but not always. 145</p> 146 147<p> 148Suppose, for example, that someone launches activity P from the home screen, 149and from there goes to activity Q. The user next presses <em>Home</em>, and then returns 150to activity P. Normally, the user would see activity Q, since that is what they 151were last doing in P's task. However, if P set this flag to "{@code true}", all 152of the activities on top of it (Q in this case) were removed when the user pressed 153<em>Home</em> and the task went to the background. So the user sees only P when returning 154to the task. 155</p> 156 157<p> 158If this attribute and <code><a href="#reparent">allowTaskReparenting</a></code> 159are both "{@code true}", any activities that can be re-parented are moved to 160the task they share an affinity with; the remaining activities are then dropped, 161as described above. 162</p></dd> 163 164<dt><a name="config"></a>{@code android:configChanges}</dt> 165<dd>Lists configuration changes that the activity will handle itself. When a configuration 166change occurs at runtime, the activity is shut down and restarted by default, but declaring a 167configuration with this attribute will prevent the activity from being restarted. Instead, the 168activity remains running and its <code>{@link android.app.Activity#onConfigurationChanged 169onConfigurationChanged()}</code> method is called. 170 171<p class="note"><strong>Note:</strong> Using this attribute should be 172avoided and used only as a last resort. Please read <a 173href="{@docRoot}guide/topics/resources/runtime-changes.html">Handling Runtime Changes</a> for more 174information about how to properly handle a restart due to a configuration change.</p> 175 176<p> 177Any or all of the following strings are valid values for this attribute. Multiple values are 178separated by '{@code |}' — for example, "{@code locale|navigation|orientation}". 179</p> 180 181<table> 182<tr> 183 <th>Value</th> 184 <th>Description</th> 185</tr><tr> 186 <td>"{@code mcc}"</td> 187 <td>The IMSI mobile country code (MCC) has changed — 188 a SIM has been detected and updated the MCC.</td> 189</tr><tr> 190 <td>"{@code mnc}"</td> 191 <td>The IMSI mobile network code (MNC) has changed — 192 a SIM has been detected and updated the MNC.</td> 193</tr><tr> 194 <td>"{@code locale}"</td> 195 <td>The locale has changed — the user has selected a new 196 language that text should be displayed in.</td> 197</tr><tr> 198 <td>"{@code touchscreen}"</td> 199 <td>The touchscreen has changed. (This should never normally happen.)</td> 200</tr><tr> 201 <td>"{@code keyboard}"</td> 202 <td>The keyboard type has changed — for example, the user has 203 plugged in an external keyboard.</td> 204</tr><tr> 205 <td>"{@code keyboardHidden}"</td> 206 <td>The keyboard accessibility has changed — for example, the 207 user has revealed the hardware keyboard.</td> 208</tr><tr> 209 <td>"{@code navigation}"</td> 210 <td>The navigation type (trackball/dpad) has changed. (This should never normally happen.)</td> 211</tr><tr> 212 <td>"{@code screenLayout}"</td> 213 <td>The screen layout has changed — this might be caused by a 214 different display being activated.</td> 215 </tr><tr> 216 <td>"{@code fontScale}"</td> 217 <td>The font scaling factor has changed — the user has selected 218 a new global font size.</td> 219 </tr><tr> 220 <td>"{@code uiMode}"</td> 221 <td>The user interface mode has changed — this can be caused when the user places the 222device into a desk/car dock or when the night mode changes. See {@link 223android.app.UiModeManager}. 224 <em>Added in API level 8</em>.</td> 225 </tr><tr> 226 <td>"{@code orientation}"</td> 227 <td>The screen orientation has changed — the user has rotated the device. 228 <p class="note"><strong>Note:</strong> If your application targets API level 13 or higher (as 229declared by the <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code 230minSdkVersion}</a> and <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code 231targetSdkVersion}</a> attributes), then you should also declare the {@code "screenSize"} 232configuration, because it also changes when a device switches between portrait and landscape 233orientations.</p></td> 234 </tr><tr> 235 <td>"{@code screenSize}"</td> 236 <td>The current available screen size has changed. This represents a change in the currently 237available size, relative to the current aspect ratio, so will change when the user switches between 238landscape and portrait. However, if your application targets API level 12 or lower, then your 239activity always handles this configuration change itself (this configuration change does not restart 240your activity, even when running on an Android 3.2 or higher device). 241 <p><em>Added in API level 13.</em></p></td> 242 </tr><tr> 243 <td>"{@code smallestScreenSize}"</td> 244 <td>The physical screen size has changed. This represents a change in size regardless of 245orientation, so will only change when the actual physical screen size has changed such as switching 246to an external display. A change to this configuration corresponds to a change in the <a 247href="{@docRoot}guide/topics/resources/providing-resources.html#SmallestScreenWidthQualifier"> 248smallestWidth configuration</a>. However, if your application targets API level 12 or lower, then 249your activity always handles this configuration change itself (this configuration change does not 250restart your activity, even when running on an Android 3.2 or higher device). 251 <p><em>Added in API level 13.</em></p></td> 252 </tr><tr> 253 <td>"{@code layoutDirection}"</td> 254 <td>The layout direction has changed. For example, changing from left-to-right (LTR) 255 to right-to-left (RTL). 256 <em>Added in API level 17.</em></td> 257 </tr> 258</table> 259 260<p> 261All of these configuration changes can impact the resource values seen by the 262application. Therefore, when <code>{@link android.app.Activity#onConfigurationChanged 263onConfigurationChanged()}</code> is called, it will generally be necessary to again 264retrieve all resources (including view layouts, drawables, and so on) to correctly 265handle the change. 266</p></dd> 267 268<dt><a name="enabled"></a>{@code android:enabled}</dt> 269<dd>Whether or not the activity can be instantiated by the system — 270"{@code true}" if it can be, and "{@code false}" if not. The default value 271is "{@code true}". 272 273<p> 274The <code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> element has its own 275<code><a href="{@docRoot}guide/topics/manifest/application-element.html#enabled">enabled</a></code> 276attribute that applies to all application components, including activities. The 277<code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> 278and {@code <activity>} attributes must both be "{@code true}" (as they both 279are by default) for the system to be able to instantiate the activity. If either 280is "{@code false}", it cannot be instantiated. 281</p></dd> 282 283<dt><a name="exclude"></a>{@code android:excludeFromRecents}</dt> 284<dd>Whether or not the task initiated by this activity should be excluded from the list of recently 285used applications ("recent apps"). That is, when this activity is the root activity of a new task, 286this attribute determines whether the task should not appear in the list of recent apps. Set "{@code 287true}" if the task should be <em>excluded</em> from the list; set "{@code false}" if it should be 288<em>included</em>. The default value is "{@code false}". 289</p></dd> 290 291<dt><a name="exported"></a>{@code android:exported}</dt> 292<dd>Whether or not the activity can be launched by components of other 293applications — "{@code true}" if it can be, and "{@code false}" if not. 294If "{@code false}", the activity can be launched only by components of the 295same application or applications with the same user ID. 296 297<p> 298The default value depends on whether the activity contains intent filters. The 299absence of any filters means that the activity can be invoked only by specifying 300its exact class name. This implies that the activity is intended only for 301application-internal use (since others would not know the class name). So in 302this case, the default value is "{@code false}". 303On the other hand, the presence of at least one filter implies that the activity 304is intended for external use, so the default value is "{@code true}". 305</p> 306 307<p> 308This attribute is not the only way to limit an activity's exposure to other 309applications. You can also use a permission to limit the external entities that 310can invoke the activity (see the 311<code><a href="{@docRoot}guide/topics/manifest/activity-element.html#prmsn">permission</a></code> 312attribute). 313</p></dd> 314 315<dt><a name="finish"></a>{@code android:finishOnTaskLaunch}</dt> 316<dd>Whether or not an existing instance of the activity should be shut down 317(finished) whenever the user again launches its task (chooses the task on the 318home screen) — "{@code true}" if it should be shut down, and "{@code false}" 319if not. The default value is "{@code false}". 320 321<p> 322If this attribute and 323<code><a href="{@docRoot}guide/topics/manifest/activity-element.html#reparent">allowTaskReparenting</a></code> 324are both "{@code true}", this attribute trumps the other. The affinity of the 325activity is ignored. The activity is not re-parented, but destroyed. 326</p> 327 328<dt><a name="hwaccel"></a>{@code android:hardwareAccelerated}</dt> 329<dd>Whether or not hardware-accelerated rendering should be enabled for this 330Activity — "{@code true}" if it should be enabled, and "{@code false}" if 331not. The default value is "{@code false}". 332 333 334<p>Starting from Android 3.0, a hardware-accelerated OpenGL renderer is 335available to applications, to improve performance for many common 2D graphics 336operations. When the hardware-accelerated renderer is enabled, most operations 337in Canvas, Paint, Xfermode, ColorFilter, Shader, and Camera are accelerated. 338This results in smoother animations, smoother scrolling, and improved 339responsiveness overall, even for applications that do not explicitly make use 340the framework's OpenGL libraries. Because of the increased resources required to 341enable hardware acceleration, your app will consume more RAM.</p> 342 343<p>Note that not all of the OpenGL 2D operations are accelerated. If you enable 344the hardware-accelerated renderer, test your application to ensure that it can 345make use of the renderer without errors.</p> 346</dd> 347 348<dt><a name="icon"></a>{@code android:icon}</dt> 349<dd>An icon representing the activity. The icon is displayed to users when 350a representation of the activity is required on-screen. For example, icons 351for activities that initiate tasks are displayed in the launcher window. 352The icon is often accompanied by a label (see the <a href="#label">{@code 353android:label}</a> attribute). 354</p> 355 356<p> 357This attribute must be set as a reference to a drawable resource containing 358the image definition. If it is not set, the icon specified for the application 359as a whole is used instead (see the 360<code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> 361element's <code><a href="{@docRoot}guide/topics/manifest/application-element.html#icon">icon</a></code> attribute). 362</p> 363 364<p> 365The activity's icon — whether set here or by the 366<code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> 367element — is also the default icon for all the activity's intent filters (see the 368<code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"><intent-filter></a></code> element's 369<code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html#icon">icon</a></code> attribute). 370</p></dd> 371 372<dt><a name="label"></a>{@code android:label}</dt> 373<dd>A user-readable label for the activity. The label is displayed on-screen 374when the activity must be represented to the user. It's often displayed along 375with the activity icon. 376 377<p> 378If this attribute is not set, the label set for the application as a whole is 379used instead (see the <code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> element's 380<code><a href="{@docRoot}guide/topics/manifest/application-element.html#label">label</a></code> attribute). 381</p> 382 383<p> 384The activity's label — whether set here or by the 385<code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> element — is also the 386default label for all the activity's intent filters (see the 387<code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"><intent-filter></a></code> element's 388<code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html#label">label</a></code> attribute). 389</p> 390 391<p> 392The label should be set as a reference to a string resource, so that 393it can be localized like other strings in the user interface. 394However, as a convenience while you're developing the application, 395it can also be set as a raw string. 396</p></dd> 397 398<dt><a name="lmode"></a>{@code android:launchMode}</dt> 399<dd>An instruction on how the activity should be launched. There are four modes 400that work in conjunction with activity flags ({@code FLAG_ACTIVITY_*} constants) 401in {@link android.content.Intent} objects to determine what should happen when 402the activity is called upon to handle an intent. They are:</p> 403 404<p style="margin-left: 2em">"{@code standard}" 405<br>"{@code singleTop}" 406<br>"{@code singleTask}" 407<br>"{@code singleInstance}"</p> 408 409<p> 410The default mode is "{@code standard}". 411</p> 412 413<p> 414As shown in the table below, the modes fall into two main groups, with 415"{@code standard}" and "{@code singleTop}" activities on one side, and 416"{@code singleTask}" and "{@code singleInstance}" activities on the other. 417An activity with the "{@code standard}" or "{@code singleTop}" launch mode 418can be instantiated multiple times. The instances can belong to any task 419and can be located anywhere in the activity stack. Typically, they're 420launched into the task that called 421<code>{@link android.content.Context#startActivity startActivity()}</code> 422(unless the Intent object contains a 423<code>{@link android.content.Intent#FLAG_ACTIVITY_NEW_TASK}</code> 424instruction, in which case a different task is chosen — see the 425<a href="#aff">taskAffinity</a> attribute). 426</p> 427 428<p> 429In contrast, "<code>singleTask</code>" and "<code>singleInstance</code>" activities 430can only begin a task. They are always at the root of the activity stack. 431Moreover, the device can hold only one instance of the activity at a time 432— only one such task. 433</p> 434 435<p> 436The "{@code standard}" and "{@code singleTop}" modes differ from each other 437in just one respect: Every time there's a new intent for a "{@code standard}" 438activity, a new instance of the class is created to respond to that intent. 439Each instance handles a single intent. 440Similarly, a new instance of a "{@code singleTop}" activity may also be 441created to handle a new intent. However, if the target task already has an 442existing instance of the activity at the top of its stack, that instance 443will receive the new intent (in an 444<code>{@link android.app.Activity#onNewIntent onNewIntent()}</code> call); 445a new instance is not created. 446In other circumstances — for example, if an existing instance of the 447"{@code singleTop}" activity is in the target task, but not at the top of 448the stack, or if it's at the top of a stack, but not in the target task 449— a new instance would be created and pushed on the stack. 450</p> 451 452<p> 453The "{@code singleTask}" and "{@code singleInstance}" modes also differ from 454each other in only one respect: A "{@code singleTask}" activity allows other 455activities to be part of its task. It's always at the root of its task, but 456other activities (necessarily "{@code standard}" and "{@code singleTop}" 457activities) can be launched into that task. A "{@code singleInstance}" 458activity, on the other hand, permits no other activities to be part of its task. 459It's the only activity in the task. If it starts another activity, that 460activity is assigned to a different task — as if {@code 461FLAG_ACTIVITY_NEW_TASK} was in the intent. 462</p> 463 464<table> 465<tr> 466<th>Use Cases</th> 467<th>Launch Mode</th> 468<th>Multiple Instances?</th> 469<th>Comments</th> 470</tr> 471<tr> 472<td rowspan="2" style="width:20%;">Normal launches for most activities</td> 473<td>"<code>standard</code>"</td> 474<td>Yes</td> 475<td>Default. The system always creates a new instance of the activity in the 476target task and routes the intent to it.</td> 477</tr> 478<tr> 479<td>"<code>singleTop</code>"</td> 480<td>Conditionally</td> 481<td>If an instance of the activity already exists at the top of the target task, 482the system routes the intent to that instance through a call to its {@link 483android.app.Activity#onNewIntent onNewIntent()} method, rather than creating a 484new instance of the activity.</td> 485</tr> 486<tr> 487<td rowspan="2">Specialized launches<br> 488<em>(not recommended for general use)</em></td> 489<td>"<code>singleTask</code>"</td> 490<td>No</td> 491<td>The system creates the activity at the root of a new task and routes the 492intent to it. However, if an instance of the activity already exists, the system 493routes the intent to existing instance through a call to its {@link 494android.app.Activity#onNewIntent onNewIntent()} method, rather than creating a 495new one.</td> 496</tr> 497<tr> 498<td>"<code>singleInstance</code>"</td> 499<td>No</td> 500<td>Same as "<code>singleTask"</code>, except that the system doesn't launch any 501other activities into the task holding the instance. The activity is always the 502single and only member of its task.</td> 503</tr> 504</table> 505 506<p>As shown in the table above, <code>standard</code> is the default mode and is 507appropriate for most types of activities. <code>SingleTop</code> is also a 508common and useful launch mode for many types of activities. The other modes 509— <code>singleTask</code> and <code>singleInstance</code> — are 510<span style="color:red">not appropriate for most applications</span>, 511since they result in an interaction model that is likely to be unfamiliar to 512users and is very different from most other applications. 513 514<p>Regardless of the launch mode that you choose, make sure to test the usability 515of the activity during launch and when navigating back to it from 516other activities and tasks using the <em>Back</em> button. </p> 517 518<p>For more information on launch modes and their interaction with Intent 519flags, see the 520<a href="{@docRoot}guide/components/tasks-and-back-stack.html">Tasks and Back Stack</a> 521document. 522</p> 523</dd> 524 525<dt><a name="multi"></a>{@code android:multiprocess}</dt> 526<dd>Whether an instance of the activity can be launched into the process of the component 527that started it — "{@code true}" if it can be, and "{@code false}" if not. 528The default value is "{@code false}". 529 530<p> 531Normally, a new instance of an activity is launched into the process of the 532application that defined it, so all instances of the activity run in the same 533process. However, if this flag is set to "{@code true}", instances of the 534activity can run in multiple processes, allowing the system to create instances 535wherever they are used (provided permissions allow it), something that is almost 536never necessary or desirable. 537</p></dd> 538 539<dt><a name="nm"></a>{@code android:name}</dt> 540<dd>The name of the class that implements the activity, a subclass of 541{@link android.app.Activity}. The attribute value should be a fully qualified 542class name (such as, "{@code com.example.project.ExtracurricularActivity}"). 543However, as a shorthand, if the first character of the name is a period 544(for example, "{@code .ExtracurricularActivity}"), it is appended to the 545package name specified in the 546<code><a href="{@docRoot}guide/topics/manifest/manifest-element.html"><manifest></a></code> 547element. 548<p>Once you publish your application, you <a 549href="http://android-developers.blogspot.com/2011/06/things-that-cannot-change.html">should not 550change this name</a> (unless you've set <code><a 551href="#exported">android:exported</a>="false"</code>).</p> 552 553<p> 554There is no default. The name must be specified. 555</p></dd> 556 557<!-- ##api level 3## --> 558<dt><a name="nohist"></a>{@code android:noHistory}</dt> 559<dd>Whether or not the activity should be removed from the activity stack and 560finished (its <code>{@link android.app.Activity#finish finish()}</code> 561method called) when the user navigates away from it and it's no longer 562visible on screen — "{@code true}" if it should be finished, and 563"{@code false}" if not. The default value is "{@code false}". 564 565<p> 566A value of "{@code true}" means that the activity will not leave a 567historical trace. It will not remain in the activity stack for the task, 568so the user will not be able to return to it. 569</p> 570 571<p> 572This attribute was introduced in API Level 3. 573</p> 574</dd> 575 576<!-- api level 16 --> 577<dt><a name="parent"></a>{@code android:parentActivityName}</dt> 578<dd>The class name of the logical parent of the activity. The name here must match the class 579 name given to the corresponding {@code <activity>} element's 580 <a href="#nm"><code>android:name</code></a> attribute. 581 582<p>The system reads this attribute to determine which activity should be started when 583 the use presses the Up button in the action bar. The system can also use this information to 584 synthesize a back stack of activities with {@link android.app.TaskStackBuilder}.</p> 585 586<p>To support API levels 4 - 16, you can also declare the parent activity with a {@code 587<meta-data>} element that specifies a value for {@code "android.support.PARENT_ACTIVITY"}. 588For example:</p> 589<pre> 590<activity 591 android:name="com.example.app.ChildActivity" 592 android:label="@string/title_child_activity" 593 android:parentActivityName="com.example.myfirstapp.MainActivity" > 594 <!-- Parent activity meta-data to support API level 4+ --> 595 <meta-data 596 android:name="android.support.PARENT_ACTIVITY" 597 android:value="com.example.app.MainActivity" /> 598</activity> 599</pre> 600 601<p>For more information about declaring the parent activity to support Up navigation, 602read <a href="{@docRoot}training/implementing-navigation/ancestral.html">Providing Up 603Navigation</a>.</p> 604 605<p> 606This attribute was introduced in API Level 16. 607</p> 608</dd> 609 610 611 612<dt><a name="prmsn"></a>{@code android:permission}</dt> 613<dd>The name of a permission that clients must have to launch the activity 614or otherwise get it to respond to an intent. If a caller of 615<code>{@link android.content.Context#startActivity startActivity()}</code> or 616<code>{@link android.app.Activity#startActivityForResult startActivityForResult()}</code> 617has not been granted the specified permission, its intent will not be 618delivered to the activity. 619 620<p> 621If this attribute is not set, the permission set by the 622<code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> 623element's 624<code><a href="{@docRoot}guide/topics/manifest/application-element.html#prmsn">permission</a></code> 625attribute applies to the activity. If neither attribute is set, the activity is 626not protected by a permission. 627</p> 628 629<p> 630For more information on permissions, see the 631<a href="{@docRoot}guide/topics/manifest/manifest-intro.html#sectperm">Permissions</a> 632section in the introduction and another document, 633<a href="{@docRoot}guide/topics/security/security.html">Security and 634Permissions</a>. 635</p></dd> 636 637<dt><a name="proc"></a>{@code android:process}</dt> 638<dd>The name of the process in which the activity should run. Normally, all components of an 639application run in a default process name created for the application and you do 640not need to use this attribute. But if necessary, you can override the default process 641name with this attribute, allowing you to spread your app components across 642multiple processes. 643 644<p> 645If the name assigned to this attribute begins with a colon (':'), a new 646process, private to the application, is created when it's needed and 647the activity runs in that process. 648If the process name begins with a lowercase character, the activity will run 649in a global process of that name, provided that it has permission to do so. 650This allows components in different applications to share a process, reducing 651resource usage. 652</p> 653 654<p>The <code><a href="{@docRoot}guide/topics/manifest/application-element.html" 655><application></a></code> element's 656<code><a href="{@docRoot}guide/topics/manifest/application-element.html#proc">process</a></code> 657attribute can set a different default process name for all components. 658</dd> 659 660<dt><a name="screen"></a>{@code android:screenOrientation}</dt> 661<dd>The orientation of the activity's display on the device. 662 663<p>The value can be any one of the following strings:</p> 664 665<table> 666<tr> 667 <td>"{@code unspecified}"</td> 668 <td>The default value. The system chooses the orientation. The policy it 669 uses, and therefore the choices made in specific contexts, may differ 670 from device to device.</td> 671</tr><tr> 672 <td>"{@code behind}"</td> 673 <td>The same orientation as the activity that's immediately beneath it in 674 the activity stack.</td> 675</tr><tr> 676 <td>"{@code landscape}"</td> 677 <td>Landscape orientation (the display is wider than it is tall).</td> 678</tr><tr> 679 <td>"{@code portrait}"</td> 680 <td>Portrait orientation (the display is taller than it is wide).</td> 681</tr><tr> 682 <td>"{@code reverseLandscape}"</td> 683 <td>Landscape orientation in the opposite direction from normal landscape. 684<em>Added in API level 9.</em></td> 685</tr><tr> 686 <td>"{@code reversePortrait}"</td> 687 <td>Portrait orientation in the opposite direction from normal portrait. 688<em>Added in API level 9.</em></td> 689</tr><tr> 690 <td>"{@code sensorLandscape}"</td> 691 <td>Landscape orientation, but can be either normal or reverse landscape based on the device 692sensor. 693<em>Added in API level 9.</em></td> 694</tr><tr> 695 <td>"{@code sensorPortrait}"</td> 696 <td>Portrait orientation, but can be either normal or reverse portrait based on the device 697sensor. 698<em>Added in API level 9.</em></td> 699</tr><tr> 700 <td>"{@code userLandscape}"</td> 701 <td>Landscape orientation, but can be either normal or reverse landscape based on the device 702sensor and the user's sensor preference. If the user has locked sensor-based rotation, this behaves 703the same as {@code landscape}, otherwise it behaves the same as {@code sensorLandscape}. 704<em>Added in API level 18.</em></td> 705</tr><tr> 706 <td>"{@code userPortrait}"</td> 707 <td>Portrait orientation, but can be either normal or reverse portrait based on the device 708sensor and the user's sensor preference. If the user has locked sensor-based rotation, this behaves 709the same as {@code portrait}, otherwise it behaves the same as {@code sensorPortrait}. 710<em>Added in API level 18.</em></td> 711</tr><tr> 712 <td>"{@code sensor}"</td> 713 <td>The orientation is determined by the device orientation sensor. The orientation of the 714display depends on how the user is holding the device; it changes when the user rotates the 715device. Some devices, though, will not rotate to all four possible orientations, by default. To 716allow all four orientations, use {@code "fullSensor"}.</td> 717</tr><tr> 718 <td>"{@code fullSensor}"</td> 719 <td>The orientation is determined by the device orientation sensor for any of the 4 orientations. 720This is similar to {@code "sensor"} except this allows any of the 4 possible screen orientations, 721regardless of what the device will normally do (for example, some devices won't normally use reverse 722portrait or reverse landscape, but this enables those). <em>Added in API level 9.</em></td> 723</tr><tr> 724 <td>"{@code nosensor}"</td> 725 <td>The orientation is determined without reference to a physical orientation sensor. The sensor 726is ignored, so the display will not rotate based on how the user moves the device. Except for this 727distinction, the system chooses the orientation using the same policy as for the "{@code 728unspecified}" setting.</td> 729</tr><tr> 730 <td>"{@code user}"</td> 731 <td>The user's current preferred orientation.</td> 732</tr><tr> 733 <td>"{@code fullUser}"</td> 734 <td>If the user has locked sensor-based rotation, this behaves the same as {@code user}, 735 otherwise it behaves the same as {@code fullSensor} and allows any of the 4 possible 736 screen orientations. 737 <em>Added in API level 18.</em></td> 738</tr><tr> 739 <td>"{@code locked}"</td> 740 <td>Locks the orientation to its current rotation, whatever that is. 741<em>Added in API level 18.</em></td> 742</tr> 743</table> 744 745<p class="note"><strong>Note:</strong> When you declare one of the landscape or portrait values, 746it is considered a hard requirement for the orientation in which the activity runs. As such, 747the value you declare enables filtering by services such as Google Play so your application is 748available only to devices that support the orientation required by your activities. For 749example, if you declare either {@code "landscape"}, {@code "reverseLandscape"}, or 750{@code "sensorLandscape"}, then your application will be available only to devices that support 751landscape orientation. However, you should also explicitly declare that 752your application requires either portrait or landscape orientation with the <a 753href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>}</a> 754element. For example, <code><uses-feature 755android:name="android.hardware.screen.portrait"/></code>. This is purely a filtering behavior 756provided by Google Play (and other services that support it) and the platform itself does not 757control whether your app can be installed when a device supports only certain orientations.</p> 758 759</dd> 760 761<dt><a name="state"></a>{@code android:stateNotNeeded}</dt> 762<dd>Whether or not the activity can be killed and successfully restarted 763without having saved its state — "{@code true}" if it can be restarted 764without reference to its previous state, and "{@code false}" if its previous 765state is required. The default value is "{@code false}". 766 767<p> 768Normally, before an activity is temporarily shut down to save resources, its 769<code>{@link android.app.Activity#onSaveInstanceState onSaveInstanceState()}</code> 770method is called. This method stores the current state of the activity in a 771{@link android.os.Bundle} object, which is then passed to 772<code>{@link android.app.Activity#onCreate onCreate()}</code> when the activity 773is restarted. If this attribute is set to "{@code true}", 774{@code onSaveInstanceState()} may not be called and {@code onCreate()} will 775be passed {@code null} instead of the Bundle — just as it was when the 776activity started for the first time. 777</p> 778 779<p> 780A "{@code true}" setting ensures that the activity can be restarted in the 781absence of retained state. For example, the activity that displays the 782home screen uses this setting to make sure that it does not get removed if it 783crashes for some reason. 784</p></dd> 785 786<dt><a name="aff"></a>{@code android:taskAffinity}</dt> 787<dd>The task that the activity has an affinity for. Activities with 788the same affinity conceptually belong to the same task (to the same 789"application" from the user's perspective). The affinity of a task 790is determined by the affinity of its root activity. 791 792<p> 793The affinity determines two things — the task that the activity is re-parented 794to (see the <code><a href="{@docRoot}guide/topics/manifest/activity-element.html#reparent">allowTaskReparenting</a></code> 795attribute) and the task that will house the activity when it is launched 796with the <code>{@link android.content.Intent#FLAG_ACTIVITY_NEW_TASK}</code> 797flag. 798</p> 799 800<p> 801By default, all activities in an application have the same affinity. You 802can set this attribute to group them differently, and even place 803activities defined in different applications within the same task. To 804specify that the activity does not have an affinity for any task, set 805it to an empty string. 806 807<p> 808If this attribute is not set, the activity inherits the affinity set 809for the application (see the 810<code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> 811element's 812<code><a href="{@docRoot}guide/topics/manifest/application-element.html#aff">taskAffinity</a></code> 813attribute). The name of the default affinity for an application is 814the package name set by the 815<code><a href="{@docRoot}guide/topics/manifest/manifest-element.html"><manifest></a></code> 816element. 817</p> 818 819<dt><a name="theme"></a>{@code android:theme}</dt> 820<dd>A reference to a style resource defining an overall theme for the activity. 821This automatically sets the activity's context to use this theme (see 822<code>{@link android.content.Context#setTheme setTheme()}</code>, and may also 823cause "starting" animations prior to the activity being launched (to better 824match what the activity actually looks like). 825 826<p> 827If this attribute is not set, the activity inherits the theme set for the 828application as a whole — from the 829<code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> 830element's 831<code><a href="{@docRoot}guide/topics/manifest/application-element.html#theme">theme</a></code> 832attribute. If that attribute is also not set, the default system theme is used. For more 833information, see the <a 834href="{@docRoot}guide/topics/ui/themes.html">Styles and Themes</a> developer guide. 835</p> 836<dd> 837 838<!-- ##api level 14## --> 839<dt><a name="uioptions"></a>{@code android:uiOptions}</dt> 840<dd>Extra options for an activity's UI. 841 <p>Must be one of the following values.</p> 842 843 <table> 844 <tr><th>Value</th><th>Description</th></tr> 845 <tr><td>{@code "none"}</td><td>No extra UI options. This is the default.</td></tr> 846 <tr><td>{@code "splitActionBarWhenNarrow"}</td><td>Add a bar at 847the bottom of the screen to display action items in the {@link android.app.ActionBar}, when 848constrained for horizontal space (such as when in portrait mode on a handset). Instead of a small 849number of action items appearing in the action bar at the top of the screen, the action bar is 850split into the top navigation section and the bottom bar for action items. This ensures a reasonable 851amount of space is made available not only for the action items, but also for navigation and title 852elements at the top. Menu items are not split across the two bars; they always appear 853together.</td></tr> 854 </table> 855 <p>For more information about the action bar, see the <a 856href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> developer guide.</p> 857 <p>This attribute was added in API level 14.</p> 858</dd> 859 860 861<!-- ##api level 3## --> 862<dt><a name="wsoft"></a>{@code android:windowSoftInputMode}</dt> 863<dd>How the main window of the activity interacts with the window containing 864the on-screen soft keyboard. The setting for this attribute affects two 865things: 866 867<ul> 868<li>The state of the soft keyboard — whether it is hidden or visible 869— when the activity becomes the focus of user attention.</li> 870 871<li>The adjustment made to the activity's main window — whether it is 872resized smaller to make room for the soft keyboard or whether its contents 873pan to make the current focus visible when part of the window is covered by 874the soft keyboard.</li> 875</ul> 876 877<p> 878The setting must be one of the values listed in the following table, or a 879combination of one "{@code state...}" value plus one "{@code adjust...}" 880value. Setting multiple values in either group — multiple 881"{@code state...}" values, for example — has undefined results. 882Individual values are separated by a vertical bar ({@code |}). For example: 883</p> 884 885<pre><activity android:windowSoftInputMode="stateVisible|adjustResize" . . . ></pre> 886 887<p> 888Values set here (other than "{@code stateUnspecified}" and 889"{@code adjustUnspecified}") override values set in the theme. 890</p> 891 892<table> 893<tr> 894 <th>Value</th> 895 <th>Description</th> 896</tr><tr> 897 <td>"{@code stateUnspecified}"</td> 898 <td>The state of the soft keyboard (whether it is hidden or visible) 899 is not specified. The system will choose an appropriate state or 900 rely on the setting in the theme. 901 902 <p> 903 This is the default setting for the behavior of the soft keyboard. 904 </p></td> 905</tr></tr> 906 <td>"{@code stateUnchanged}"</td> 907 <td>The soft keyboard is kept in whatever state it was last in, 908 whether visible or hidden, when the activity comes to the fore.</td> 909</tr></tr> 910 <td>"{@code stateHidden}"</td> 911 <td>The soft keyboard is hidden when the user chooses the activity 912 — that is, when the user affirmatively navigates forward to the 913 activity, rather than backs into it because of leaving another activity.</td> 914</tr></tr> 915 <td>"{@code stateAlwaysHidden}"</td> 916 <td>The soft keyboard is always hidden when the activity's main window 917 has input focus.</td> 918</tr></tr> 919 <td>"{@code stateVisible}"</td> 920 <td>The soft keyboard is visible when that's normally appropriate 921 (when the user is navigating forward to the activity's main window).</td> 922</tr></tr> 923 <td>"{@code stateAlwaysVisible}"</td> 924 <td>The soft keyboard is made visible when the user chooses the 925 activity — that is, when the user affirmatively navigates forward 926 to the activity, rather than backs into it because of leaving another 927 activity.</td> 928</tr></tr> 929 <td>"{@code adjustUnspecified}"</td> 930 <td>It is unspecified whether the activity's main window resizes 931 to make room for the soft keyboard, or whether the contents 932 of the window pan to make the current focus visible on-screen. 933 The system will automatically select one of these modes depending 934 on whether the content of the window has any layout views that 935 can scroll their contents. If there is such a view, the window 936 will be resized, on the assumption that scrolling can make all 937 of the window's contents visible within a smaller area. 938 939 <p> 940 This is the default setting for the behavior of the main window. 941 </p></td> 942</tr></tr> 943 <td>"{@code adjustResize}"</td> 944 <td>The activity's main window is always resized to make room for 945 the soft keyboard on screen.</td> 946</tr></tr> 947 <td>"{@code adjustPan}"</td> 948 <td>The activity's main window is not resized to make room for the soft 949 keyboard. Rather, the contents of the window are automatically 950 panned so that the current focus is never obscured by the keyboard 951 and users can always see what they are typing. This is generally less 952 desirable than resizing, because the user may need to close the soft 953 keyboard to get at and interact with obscured parts of the window.</td> 954</tr> 955</table> 956 957<p> 958This attribute was introduced in API Level 3. 959</p></dd> 960</dl></dd> 961 962<!-- ##api level indication## --> 963<dt>introduced in:</dt> 964<dd>API Level 1 for all attributes except for 965<code><a href="#nohist">noHistory</a></code> and 966<code><a href="#wsoft">windowSoftInputMode</a></code>, which were added in API 967Level 3.</dd> 968 969<dt>see also:</dt> 970<dd><code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> 971<br/><code><a href="{@docRoot}guide/topics/manifest/activity-alias-element.html"><activity-alias></a></code></dd> 972</dl> 973