Home | History | Annotate | Download | only in manifest
      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">&lt;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"] &gt;   <!-- ##api level 3## -->
     46     . . .
     47 &lt;/activity&gt;</pre></dd>
     48 
     49 <dt>contained in:</dt>
     50 <dd><code><a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code></dd>
     51 
     52 <dt>can contain:</dt>
     53 <dd><code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></code>
     54 <br/><code><a href="{@docRoot}guide/topics/manifest/meta-data-element.html">&lt;meta-data&gt;</a></code></dd>
     55 
     56 <dt>description:</dt>
     57 <dd>Declares an activity (an {@link android.app.Activity} subclass) that
     58 implements part of the application's visual user interface.  All activities
     59 must be represented by {@code &lt;activity&gt;}
     60 elements in the manifest file.  Any that are not declared there will not be seen
     61 by 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
     67 the task it has an affinity for when that task is next brought to the
     68 front &mdash; "{@code true}" if it can move, and "{@code false}" if it
     69 must remain with the task where it started.
     70 
     71 <p>
     72 If 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>
     74 attribute of the <code><a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code> element
     75 applies to the activity.  The default value is "{@code false}".
     76 </p>
     77 
     78 <p>
     79 Normally when an activity is started, it's associated with the task of
     80 the activity that started it and it stays there for its entire lifetime.
     81 You can use this attribute to force it to be re-parented to the task it
     82 has an affinity for when its current task is no longer displayed.
     83 Typically, it's used to cause the activities of an application to move
     84 to the main task associated with that application.
     85 </p>
     86 
     87 <p>
     88 For example, if an e-mail message contains a link to a web page, clicking
     89 the link brings up an activity that can display the page.  That activity
     90 is defined by the browser application, but is launched as part of the e-mail
     91 task.  If it's reparented to the browser task, it will be shown when the
     92 browser next comes to the front, and will be absent when the e-mail task
     93 again comes forward.
     94 </p>
     95 
     96 <p>
     97 The affinity of an activity is defined by the
     98 <code><a href="#aff">taskAffinity</a></code> attribute.  The affinity
     99 of a task is determined by reading the affinity of its root activity.
    100 Therefore, by definition, a root activity is always in a task with the
    101 same affinity.  Since activities with "{@code singleTask}" or
    102 "{@code singleInstance}" launch modes can only be at the root of a task,
    103 re-parenting is limited to the "{@code standard}" and "{@code singleTop}"
    104 modes.  (See also the <code><a href="#lmode">launchMode</a></code>
    105 attribute.)
    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
    110 be maintained by the system &mdash; "{@code true}" if it will be, and
    111 "{@code false}" if the system is allowed to reset the task to its initial
    112 state in certain situations.  The default value is "{@code false}".  This
    113 attribute is meaningful only for the root activity of a task; it's ignored
    114 for all other activities.
    115 
    116 <p>
    117 Normally, the system clears a task (removes all activities from the stack
    118 above the root activity) in certain situations when the user re-selects that
    119 task from the home screen.  Typically, this is done if the user hasn't visited
    120 the task for a certain amount of time, such as 30 minutes.
    121 </p>
    122 
    123 <p>
    124 However, when this attribute is "{@code true}", users will always return
    125 to the task in its last state, regardless of how they get there.  This is
    126 useful, for example, in an application like the web browser where there is
    127 a 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
    132 the root activity, whenever it is re-launched from the home screen &mdash;
    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
    135 is meaningful only for activities that start a new task (the root activity);
    136 it's ignored for all other activities in the task.
    137 
    138 <p>
    139 When the value is "{@code true}", every time users start the task again, they
    140 are brought to its root activity regardless of what they were last doing in
    141 the task and regardless of whether they used the <em>Back</em> or <em>Home</em> button to
    142 leave it. When the value is "{@code false}", the task may be cleared of activities in
    143 some situations (see the
    144 <code><a href="#always">alwaysRetainTaskState</a></code> attribute), but not always.
    145 </p>
    146 
    147 <p>
    148 Suppose, for example, that someone launches activity P from the home screen,
    149 and from there goes to activity Q.  The user next presses <em>Home</em>, and then returns
    150 to activity P.  Normally, the user would see activity Q, since that is what they
    151 were last doing in P's task.  However, if P set this flag to "{@code true}", all
    152 of 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
    154 to the task.
    155 </p>
    156 
    157 <p>
    158 If this attribute and <code><a href="#reparent">allowTaskReparenting</a></code>
    159 are both "{@code true}", any activities that can be re-parented are moved to
    160 the task they share an affinity with; the remaining activities are then dropped,
    161 as 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
    166 change occurs at runtime, the activity is shut down and restarted by default, but declaring a
    167 configuration with this attribute will prevent the activity from being restarted. Instead, the
    168 activity remains running and its <code>{@link android.app.Activity#onConfigurationChanged
    169 onConfigurationChanged()}</code> method is called.
    170 
    171 <p class="note"><strong>Note:</strong> Using this attribute should be
    172 avoided and used only as a last resort. Please read <a
    173 href="{@docRoot}guide/topics/resources/runtime-changes.html">Handling Runtime Changes</a> for more
    174 information about how to properly handle a restart due to a configuration change.</p>
    175 
    176 <p>
    177 Any or all of the following strings are valid values for this attribute. Multiple values are
    178 separated by '{@code |}' &mdash; 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 &mdash;
    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 &mdash;
    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 &mdash; 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 &mdash; 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 &mdash; 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 &mdash; 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 &mdash; 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 &mdash; this can be caused when the user places the
    222 device into a desk/car dock or when the night mode changes. See {@link
    223 android.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 &mdash; the user has rotated the device.
    228        <p class="note"><strong>Note:</strong> If your application targets API level 13 or higher (as
    229 declared by the <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code
    230 minSdkVersion}</a> and <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code
    231 targetSdkVersion}</a> attributes), then you should also declare the {@code "screenSize"}
    232 configuration, because it also changes when a device switches between portrait and landscape
    233 orientations.</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
    237 available size, relative to the current aspect ratio, so will change when the user switches between
    238 landscape and portrait. However, if your application targets API level 12 or lower, then your
    239 activity always handles this configuration change itself (this configuration change does not restart
    240 your 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
    245 orientation, so will only change when the actual physical screen size has changed such as switching
    246 to an external display. A change to this configuration corresponds to a change in the <a
    247 href="{@docRoot}guide/topics/resources/providing-resources.html#SmallestScreenWidthQualifier">
    248 smallestWidth configuration</a>. However, if your application targets API level 12 or lower, then
    249 your activity always handles this configuration change itself (this configuration change does not
    250 restart 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>
    261 All of these configuration changes can impact the resource values seen by the
    262 application.  Therefore, when <code>{@link android.app.Activity#onConfigurationChanged
    263 onConfigurationChanged()}</code> is called, it will generally be necessary to again
    264 retrieve all resources (including view layouts, drawables, and so on) to correctly
    265 handle 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 &mdash;
    270 "{@code true}" if it can be, and "{@code false}" if not.  The default value
    271 is "{@code true}".
    272 
    273 <p>
    274 The <code><a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code> element has its own
    275 <code><a href="{@docRoot}guide/topics/manifest/application-element.html#enabled">enabled</a></code>
    276 attribute that applies to all application components, including activities.  The
    277 <code><a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code>
    278 and {@code &lt;activity&gt;} attributes must both be "{@code true}" (as they both
    279 are by default) for the system to be able to instantiate the activity.  If either
    280 is "{@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
    285 used applications ("recent apps"). That is, when this activity is the root activity of a new task,
    286 this attribute determines whether the task should not appear in the list of recent apps. Set "{@code
    287 true}" 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
    293 applications &mdash; "{@code true}" if it can be, and "{@code false}" if not.
    294 If "{@code false}", the activity can be launched only by components of the
    295 same application or applications with the same user ID.
    296 
    297 <p>
    298 The default value depends on whether the activity contains intent filters.  The
    299 absence of any filters means that the activity can be invoked only by specifying
    300 its exact class name.  This implies that the activity is intended only for
    301 application-internal use (since others would not know the class name).  So in
    302 this case, the default value is "{@code false}".
    303 On the other hand, the presence of at least one filter implies that the activity
    304 is intended for external use, so the default value is "{@code true}".
    305 </p>
    306 
    307 <p>
    308 This attribute is not the only way to limit an activity's exposure to other
    309 applications.  You can also use a permission to limit the external entities that
    310 can invoke the activity  (see the
    311 <code><a href="{@docRoot}guide/topics/manifest/activity-element.html#prmsn">permission</a></code>
    312 attribute).
    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
    318 home screen) &mdash; "{@code true}" if it should be shut down, and "{@code false}"
    319 if not. The default value is "{@code false}".
    320 
    321 <p>
    322 If this attribute and
    323 <code><a href="{@docRoot}guide/topics/manifest/activity-element.html#reparent">allowTaskReparenting</a></code>
    324 are both "{@code true}", this attribute trumps the other.  The affinity of the
    325 activity 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
    330 Activity &mdash; "{@code true}" if it should be enabled, and "{@code false}" if
    331 not. The default value is "{@code false}".
    332 
    333 
    334 <p>Starting from Android 3.0, a hardware-accelerated OpenGL renderer is
    335 available to applications, to improve performance for many common 2D graphics
    336 operations. When the hardware-accelerated renderer is enabled, most operations
    337 in Canvas, Paint, Xfermode, ColorFilter, Shader, and Camera are accelerated.
    338 This results in smoother animations, smoother scrolling, and improved
    339 responsiveness overall, even for applications that do not explicitly make use
    340 the framework's OpenGL libraries. Because of the increased resources required to
    341 enable 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
    344 the hardware-accelerated renderer, test your application to ensure that it can
    345 make 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
    350 a representation of the activity is required on-screen.  For example, icons
    351 for activities that initiate tasks are displayed in the launcher window.
    352 The icon is often accompanied by a label (see the <a href="#label">{@code
    353 android:label}</a> attribute).
    354 </p>
    355 
    356 <p>
    357 This attribute must be set as a reference to a drawable resource containing
    358 the image definition.  If it is not set, the icon specified for the application
    359 as a whole is used instead (see the
    360 <code><a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code>
    361 element's <code><a href="{@docRoot}guide/topics/manifest/application-element.html#icon">icon</a></code> attribute).
    362 </p>
    363 
    364 <p>
    365 The activity's icon &mdash; whether set here or by the
    366 <code><a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code>
    367 element &mdash; 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">&lt;intent-filter&gt;</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
    374 when the activity must be represented to the user. It's often displayed along
    375 with the activity icon.
    376 
    377 <p>
    378 If this attribute is not set, the label set for the application as a whole is
    379 used instead (see the <code><a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</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>
    384 The activity's label &mdash; whether set here or by the
    385 <code><a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code> element &mdash; is also the
    386 default label for all the activity's intent filters (see the
    387 <code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</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>
    392 The label should be set as a reference to a string resource, so that
    393 it can be localized like other strings in the user interface.
    394 However, as a convenience while you're developing the application,
    395 it 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
    400 that work in conjunction with activity flags ({@code FLAG_ACTIVITY_*} constants)
    401 in {@link android.content.Intent} objects to determine what should happen when
    402 the 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>
    410 The default mode is "{@code standard}".
    411 </p>
    412 
    413 <p>
    414 As 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.
    417 An activity with the "{@code standard}" or "{@code singleTop}" launch mode
    418 can be instantiated multiple times.  The instances can belong to any task
    419 and can be located anywhere in the activity stack.  Typically, they're
    420 launched 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>
    424 instruction, in which case a different task is chosen &mdash; see the
    425 <a href="#aff">taskAffinity</a> attribute).
    426 </p>
    427 
    428 <p>
    429 In contrast, "<code>singleTask</code>" and "<code>singleInstance</code>" activities
    430 can only begin a task.  They are always at the root of the activity stack.
    431 Moreover, the device can hold only one instance of the activity at a time
    432 &mdash; only one such task.
    433 </p>
    434 
    435 <p>
    436 The "{@code standard}" and "{@code singleTop}" modes differ from each other
    437 in just one respect:  Every time there's a new intent for a "{@code standard}"
    438 activity, a new instance of the class is created to respond to that intent.
    439 Each instance handles a single intent.
    440 Similarly, a new instance of a "{@code singleTop}" activity may also be
    441 created to handle a new intent.  However, if the target task already has an
    442 existing instance of the activity at the top of its stack, that instance
    443 will receive the new intent (in an
    444 <code>{@link android.app.Activity#onNewIntent onNewIntent()}</code> call);
    445 a new instance is not created.
    446 In other circumstances &mdash; for example, if an existing instance of the
    447 "{@code singleTop}" activity is in the target task, but not at the top of
    448 the stack, or if it's at the top of a stack, but not in the target task
    449 &mdash; a new instance would be created and pushed on the stack.
    450 </p>
    451 
    452 <p>
    453 The "{@code singleTask}" and "{@code singleInstance}" modes also differ from
    454 each other in only one respect:  A "{@code singleTask}" activity allows other
    455 activities to be part of its task. It's always at the root of its task, but
    456 other activities (necessarily "{@code standard}" and "{@code singleTop}"
    457 activities) can be launched into that task.  A "{@code singleInstance}"
    458 activity, on the other hand, permits no other activities to be part of its task.
    459 It's the only activity in the task.  If it starts another activity, that
    460 activity is assigned to a different task &mdash; as if {@code
    461 FLAG_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
    476 target 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,
    482 the system routes the intent to that instance through a call to its {@link
    483 android.app.Activity#onNewIntent onNewIntent()} method, rather than creating a
    484 new 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
    492 intent to it. However, if an instance of the activity already exists, the system
    493 routes the intent to existing instance through a call to its {@link
    494 android.app.Activity#onNewIntent onNewIntent()} method, rather than creating a
    495 new 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
    501 other activities into the task holding the instance. The activity is always the
    502 single 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
    507 appropriate for most types of activities. <code>SingleTop</code> is also a
    508 common and useful launch mode for many types of activities. The other modes
    509 &mdash; <code>singleTask</code> and <code>singleInstance</code> &mdash; are
    510 <span style="color:red">not appropriate for most applications</span>,
    511 since they result in an interaction model that is likely to be unfamiliar to
    512 users 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
    515 of the activity during launch and when navigating back to it from
    516 other activities and tasks using the <em>Back</em> button. </p>
    517 
    518 <p>For more information on launch modes and their interaction with Intent
    519 flags, see the
    520 <a href="{@docRoot}guide/components/tasks-and-back-stack.html">Tasks and Back Stack</a>
    521 document.
    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
    527 that started it &mdash; "{@code true}" if it can be, and "{@code false}" if not.
    528 The default value is "{@code false}".
    529 
    530 <p>
    531 Normally, a new instance of an activity is launched into the process of the
    532 application that defined it, so all instances of the activity run in the same
    533 process.  However, if this flag is set to "{@code true}", instances of the
    534 activity can run in multiple processes, allowing the system to create instances
    535 wherever they are used (provided permissions allow it), something that is almost
    536 never 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
    542 class name (such as, "{@code com.example.project.ExtracurricularActivity}").
    543 However, as a shorthand, if the first character of the name is a period
    544 (for example, "{@code .ExtracurricularActivity}"), it is appended to the
    545 package name specified in the
    546 <code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code>
    547 element.
    548 <p>Once you publish your application, you <a
    549 href="http://android-developers.blogspot.com/2011/06/things-that-cannot-change.html">should not
    550 change this name</a> (unless you've set <code><a
    551 href="#exported">android:exported</a>="false"</code>).</p>
    552 
    553 <p>
    554 There 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
    560 finished (its <code>{@link android.app.Activity#finish finish()}</code>
    561 method called) when the user navigates away from it and it's no longer
    562 visible on screen &mdash; "{@code true}" if it should be finished, and
    563 "{@code false}" if not.  The default value is "{@code false}".
    564 
    565 <p>
    566 A value of "{@code true}" means that the activity will not leave a
    567 historical trace.  It will not remain in the activity stack for the task,
    568 so the user will not be able to return to it.
    569 </p>
    570 
    571 <p>
    572 This 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 &lt;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 &lt;meta-data>} element that specifies a value for {@code "android.support.PARENT_ACTIVITY"}.
    588 For example:</p>
    589 <pre>
    590 &lt;activity
    591     android:name="com.example.app.ChildActivity"
    592     android:label="@string/title_child_activity"
    593     android:parentActivityName="com.example.myfirstapp.MainActivity" >
    594     &lt;!-- Parent activity meta-data to support API level 4+ -->
    595     &lt;meta-data
    596         android:name="android.support.PARENT_ACTIVITY"
    597         android:value="com.example.app.MainActivity" />
    598 &lt;/activity>
    599 </pre>
    600 
    601 <p>For more information about declaring the parent activity to support Up navigation,
    602 read <a href="{@docRoot}training/implementing-navigation/ancestral.html">Providing Up
    603 Navigation</a>.</p>
    604 
    605 <p>
    606 This 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
    614 or 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>
    617 has not been granted the specified permission, its intent will not be
    618 delivered to the activity.
    619 
    620 <p>
    621 If this attribute is not set, the permission set by the
    622 <code><a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code>
    623 element's
    624 <code><a href="{@docRoot}guide/topics/manifest/application-element.html#prmsn">permission</a></code>
    625 attribute applies to the activity.  If neither attribute is set, the activity is
    626 not protected by a permission.
    627 </p>
    628 
    629 <p>
    630 For more information on permissions, see the
    631 <a href="{@docRoot}guide/topics/manifest/manifest-intro.html#sectperm">Permissions</a>
    632 section in the introduction and another document,
    633 <a href="{@docRoot}guide/topics/security/security.html">Security and
    634 Permissions</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
    639 application run in a default process name created for the application and you do
    640 not need to use this attribute. But if necessary, you can override the default process
    641 name with this attribute, allowing you to spread your app components across
    642 multiple processes.
    643 
    644 <p>
    645 If the name assigned to this attribute begins with a colon (':'), a new
    646 process, private to the application, is created when it's needed and
    647 the activity runs in that process.
    648 If the process name begins with a lowercase character, the activity will run
    649 in a global process of that name, provided that it has permission to do so.
    650 This allows components in different applications to share a process, reducing
    651 resource usage.
    652 </p>
    653 
    654 <p>The <code><a href="{@docRoot}guide/topics/manifest/application-element.html"
    655 >&lt;application&gt;</a></code> element's
    656 <code><a href="{@docRoot}guide/topics/manifest/application-element.html#proc">process</a></code>
    657 attribute 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
    692 sensor.
    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
    697 sensor.
    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
    702 sensor and the user's sensor preference. If the user has locked sensor-based rotation, this behaves
    703 the 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
    708 sensor and the user's sensor preference. If the user has locked sensor-based rotation, this behaves
    709 the 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
    714 display depends on how the user is holding the device; it changes when the user rotates the
    715 device. Some devices, though, will not rotate to all four possible orientations, by default. To
    716 allow 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.
    720 This is similar to {@code "sensor"} except this allows any of the 4 possible screen orientations,
    721 regardless of what the device will normally do (for example, some devices won't normally use reverse
    722 portrait 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
    726 is ignored, so the display will not rotate based on how the user moves the device.  Except for this
    727 distinction, the system chooses the orientation using the same policy as for the "{@code
    728 unspecified}" 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,
    746 it is considered a hard requirement for the orientation in which the activity runs. As such,
    747 the value you declare enables filtering by services such as Google Play so your application is
    748 available only to devices that support the orientation required by your activities. For
    749 example, if you declare either {@code "landscape"}, {@code "reverseLandscape"}, or
    750 {@code "sensorLandscape"}, then your application will be available only to devices that support
    751 landscape orientation. However, you should also explicitly declare that
    752 your application requires either portrait or landscape orientation with the <a
    753 href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a>
    754 element. For example, <code>&lt;uses-feature
    755 android:name="android.hardware.screen.portrait"/></code>. This is purely a filtering behavior
    756 provided by Google Play (and other services that support it) and the platform itself does not
    757 control 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
    763 without having saved its state &mdash; "{@code true}" if it can be restarted
    764 without reference to its previous state, and "{@code false}" if its previous
    765 state is required.  The default value is "{@code false}".
    766 
    767 <p>
    768 Normally, before an activity is temporarily shut down to save resources, its
    769 <code>{@link android.app.Activity#onSaveInstanceState onSaveInstanceState()}</code>
    770 method 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
    773 is restarted.  If this attribute is set to "{@code true}",
    774 {@code onSaveInstanceState()} may not be called and {@code onCreate()} will
    775 be passed {@code null} instead of the Bundle &mdash; just as it was when the
    776 activity started for the first time.
    777 </p>
    778 
    779 <p>
    780 A "{@code true}" setting ensures that the activity can be restarted in the
    781 absence of retained state.  For example, the activity that displays the
    782 home screen uses this setting to make sure that it does not get removed if it
    783 crashes 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
    788 the same affinity conceptually belong to the same task (to the same
    789 "application" from the user's perspective).  The affinity of a task
    790 is determined by the affinity of its root activity.
    791 
    792 <p>
    793 The affinity determines two things &mdash; the task that the activity is re-parented
    794 to (see the <code><a href="{@docRoot}guide/topics/manifest/activity-element.html#reparent">allowTaskReparenting</a></code>
    795 attribute) and the task that will house the activity when it is launched
    796 with the <code>{@link android.content.Intent#FLAG_ACTIVITY_NEW_TASK}</code>
    797 flag.
    798 </p>
    799 
    800 <p>
    801 By default, all activities in an application have the same affinity.  You
    802 can set this attribute to group them differently, and even place
    803 activities defined in different applications within the same task.  To
    804 specify that the activity does not have an affinity for any task, set
    805 it to an empty string.
    806 
    807 <p>
    808 If this attribute is not set, the activity inherits the affinity set
    809 for the application (see the
    810 <code><a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code>
    811 element's
    812 <code><a href="{@docRoot}guide/topics/manifest/application-element.html#aff">taskAffinity</a></code>
    813 attribute).  The name of the default affinity for an application is
    814 the package name set by the
    815 <code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code>
    816 element.
    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.
    821 This automatically sets the activity's context to use this theme (see
    822 <code>{@link android.content.Context#setTheme setTheme()}</code>, and may also
    823 cause "starting" animations prior to the activity being launched (to better
    824 match what the activity actually looks like).
    825 
    826 <p>
    827 If this attribute is not set, the activity inherits the theme set for the
    828 application as a whole &mdash; from the
    829 <code><a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code>
    830 element's
    831 <code><a href="{@docRoot}guide/topics/manifest/application-element.html#theme">theme</a></code>
    832 attribute.  If that attribute is also not set, the default system theme is used. For more
    833 information, see the <a
    834 href="{@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
    847 the bottom of the screen to display action items in the {@link android.app.ActionBar}, when
    848 constrained for horizontal space (such as when in portrait mode on a handset). Instead of a small
    849 number of action items appearing in the action bar at the top of the screen, the action bar is
    850 split into the top navigation section and the bottom bar for action items. This ensures a reasonable
    851 amount of space is made available not only for the action items, but also for navigation and title
    852 elements at the top. Menu items are not split across the two bars; they always appear
    853 together.</td></tr>
    854   </table>
    855   <p>For more information about the action bar, see the <a
    856 href="{@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
    864 the on-screen soft keyboard.  The setting for this attribute affects two
    865 things:
    866 
    867 <ul>
    868 <li>The state of the soft keyboard &mdash; whether it is hidden or visible
    869 &mdash; when the activity becomes the focus of user attention.</li>
    870 
    871 <li>The adjustment made to the activity's main window &mdash; whether it is
    872 resized smaller to make room for the soft keyboard or whether its contents
    873 pan to make the current focus visible when part of the window is covered by
    874 the soft keyboard.</li>
    875 </ul>
    876 
    877 <p>
    878 The setting must be one of the values listed in the following table, or a
    879 combination of one "{@code state...}" value plus one "{@code adjust...}"
    880 value.  Setting multiple values in either group &mdash; multiple
    881 "{@code state...}" values, for example &mdash; has undefined results.
    882 Individual values are separated by a vertical bar ({@code |}).  For example:
    883 </p>
    884 
    885 <pre>&lt;activity android:windowSoftInputMode="stateVisible|adjustResize" . . . &gt;</pre>
    886 
    887 <p>
    888 Values 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        &mdash; 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 &mdash; 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>
    958 This 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
    967 Level 3.</dd>
    968 
    969 <dt>see also:</dt>
    970 <dd><code><a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code>
    971 <br/><code><a href="{@docRoot}guide/topics/manifest/activity-alias-element.html">&lt;activity-alias&gt;</a></code></dd>
    972 </dl>
    973