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