manifest-element.jd revision 2a1b706ec11e53689a2f86cc8e558e74591b462a
1page.title=<manifest> 2parent.title=The AndroidManifest.xml File 3parent.link=manifest-intro.html 4@jd:body 5 6<dl class="xml"> 7<dt>syntax:</dt> 8<dd><pre class="stx"><manifest xmlns:<a href="#nspace">android</a>="http://schemas.android.com/apk/res/android" 9 <a href="#package">package</a>="<i>string</i>" 10 android:<a href="#uid">sharedUserId</a>="<i>string</i>" 11 android:<a href="#uidlabel">sharedUserLabel</a>="<i>string resource</i>" <!-- ##api level 3## --> 12 android:<a href="#vcode">versionCode</a>="<i>integer</i>" 13 android:<a href="#vname">versionName</a>="<i>string</i>" 14 android:<a href="#install">installLocation</a>=["auto" | "internalOnly" | "preferExternal"] > 15 . . . 16</manifest></pre></dd> 17 18<p> 19<dt>contained in:</dt> 20<dd><i>none</i></dd> 21 22<p> 23<p> 24<dt>must contain:</dt> 25<dd><code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code></dd> 26 27<dt>can contain:</dt> 28<dd><code><a href="{@docRoot}guide/topics/manifest/instrumentation-element.html"><instrumentation></a></code> 29<br/><code><a href="{@docRoot}guide/topics/manifest/permission-element.html"><permission></a></code> 30<br/><code><a href="{@docRoot}guide/topics/manifest/permission-group-element.html"><permission-group></a></code> 31<br/><code><a href="{@docRoot}guide/topics/manifest/permission-tree-element.html"><permission-tree></a></code> 32<br/><code><a href="{@docRoot}guide/topics/manifest/uses-configuration-element.html"><uses-configuration></a></code> <!-- ##api level 3## --> 33<br/><code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html"><uses-permission></a></code></dd> 34<br/><code><a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html"><uses-sdk></a></code></dd> 35 36<p> 37<dt>description:</dt> 38<dd>The root element of the AndroidManifest.xml file. It must 39contain an <code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> element 40and specify {@code xlmns:android} and {@code package} attributes.</dd> 41 42<dt>attributes:</dt> 43<dd> 44<dl class="attr"> 45<dt><a name="nspace"></a>{@code xmlns:android}</dt> 46<dd>Defines the Android namespace. This attribute should always be set 47to "{@code http://schemas.android.com/apk/res/android}".</dd> 48 49<dt><a name="package"></a>{@code package}</dt> 50<dd>A full Java package name for the application. The name should 51be unique. The name may contain uppercase or lowercase letters ('A' 52through 'Z'), numbers, and underscores ('_'). However, individual 53package name parts may only start with letters. For example, applications 54published by Google could have names in the form 55<code>com.google.app.<i>application_name</i></code>. 56 57 <p> 58 The package name serves as a unique identifier for the application. 59 It's also the default name for the application process (see the 60 <code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> 61 element's 62 <code><a href="{@docRoot}guide/topics/manifest/application-element.html#aff">process</a></code> 63 process</a></code> attribute) and the default task affinity of an activity 64 (see the 65 <code><a href="{@docRoot}guide/topics/manifest/activity-element.html"><activity></a></code> 66 element's 67 <code><a href="{@docRoot}guide/topics/manifest/activity-element.html#aff">taskAffinity</a></code> attribute). 68 </p> 69</dd> 70 71<dt><a name="uid"></a>{@code android:sharedUserId}</dt> 72<dd>The name of a Linux user ID that will be shared with other applications. 73By default, Android assigns each application its own unique user ID. 74However, if this attribute is set to the same value for two or more applications, 75they will all share the same ID — provided that they are also signed 76by the same certificate. Application with the same user ID can access each 77other's data and, if desired, run in the same process.</dd> 78 79<dt><a name="uidlabel"></a>{@code android:sharedUserLabel}</dt> 80<dd>A user-readable label for the shared user ID. The label must be set as 81a reference to a string resource; it cannot be a raw string. 82 83 <p> 84 <!-- ##api level indication## --> 85 This attribute was introduced in API Level 3. It is meaningful only if the 86 <code><a href="#uid">sharedUserId</a></code> attribute is also set. 87 </p> 88</dd> 89 90<dt><a name="vcode"></a>{@code android:versionCode}</dt> 91<dd>An internal version number. This number is used only to determine whether 92one version is more recent than another, with higher numbers indicating more 93recent versions. This is not the version number shown to users; that number 94is set by the {@code versionName} attribute. 95 96 <p> 97 The value must be set as an integer, such as "100". You can define it however 98 you want, as long as each successive version has a higher number. For example, 99 it could be a build number. Or you could translate a version number in "x.y" 100 format to an integer by encoding the "x" and "y" separately in the lower and 101 upper 16 bits. Or you could simply increase the number by one each time a new 102 version is released. 103 </p> 104</dd> 105 106<dt><a name="vname"></a>{@code android:versionName}</dt> 107<dd>The version number shown to users. This attribute can be set as a raw 108string or as a reference to a string resource. The string has no other purpose 109than to be displayed to users. The {@code versionCode} attribute holds 110the significant version number used internally. 111</dd> 112 113<dt><a name="install"></a>{@code android:installLocation}</dt> 114<dd>The default install location for the application. 115 116<p>The following keyword strings are accepted:</p> 117 118<table> 119<tr> 120 <th>Value</th> 121 <th>Description</th> 122</tr><tr> 123 <td>"{@code internalOnly}"</td> 124 <td>The application must be installed on the internal device storage only. If this is set, 125the application will never be installed on the external storage. If the internal 126storage is full, then the system will not install the application. This is also the default behavior 127if you do not define {@code android:installLocation}.</td> 128</tr><tr> 129 <td>"{@code auto}"</td> 130 <td>The application may be installed on the external storage, but the system will install the 131application on the internal storage by default. If the internal storage is full, then the system 132will install it on the external storage. Once installed, the user can move the application 133to either internal or external storage through the system settings.</td> 134</tr><tr> 135 <td>"{@code preferExternal}"</td> 136 <td>The application prefers to be installed on the external storage (SD card). There is no 137guarantee that the system will honor this request. The application might be installed on internal 138storage if the external media is unavailable or full, or if the application uses the forward-locking 139mechanism (not supported on external storage). Once installed, the user can move the application to 140either internal or external storage through the system settings.</td> 141</tr> 142</table> 143 144<p class="note"><strong>Note:</strong> By default, your application will be installed on the 145internal storage and cannot be installed on the external storage unless you define this attribute 146to be either "{@code auto}" or "{@code preferExternal}".</p> 147 148<p>When an application is installed on the external storage:</p> 149<ul> 150 <li>The {@code .apk} file is saved 151to the external storage, but any application data (such as databases) is still saved on 152the internal device memory.</li> 153 <li>The container in which the {@code .apk} file is saved is encrypted with a key that allows 154the application to operate only on the device that installed it. (A user cannot 155transfer the SD card to another device and use applications installed on the card.) Though, 156multiple SD cards can be used with the same device.</li> 157 <li>At the user's request, the application can be moved to the internal storage.</li> 158</ul> 159 160<p>The user may also request to move an application from the internal storage to the external 161storage. However, the system will not allow the user to move the application to external storage if 162this attribute is set to {@code internalOnly}, which is the default setting.</p> 163 164<p>Read <a href="{@docRoot}guide/appendix/install-location.html">App Install Location</a> for 165more information about using this attribute (including how to maintain backward compatibility).</p> 166 167<p>Introduced in: API Level 8.</p> 168 169 170</dd> 171 172</dl> 173</dd><!-- end attributes --> 174 175<!-- ##api level indication## --> 176<dt>introduced in:</dt> 177<dd>API Level 1 for all attributes, unless noted otherwise in the attribute description.</dd> 178 179<p> 180<dt>see also:</dt> 181<dd> 182<code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code></dd> 183 184</dl> 185