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