• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1page.title=<uses-permission>
2parent.title=The AndroidManifest.xml File
3parent.link=manifest-intro.html
4@jd:body
5
6<dl class="xml">
7
8<div class="sidebox-wrapper">
9<div class="sidebox">
10<img src="{@docRoot}assets/images/icon_play.png" style="float:left;margin:0;padding:0;">
11<p style="color:#669999;padding-top:1em;">Google Play Filtering</p>
12
13<p style="clear:left;">In some cases, the permissions that you request
14through <code>&lt;uses-permission&gt;</code> can affect how
15your application is filtered by Google Play.</p>
16
17<p>If you request a hardware-related permission &mdash;
18<code>CAMERA</code>, for example &mdash; Google Play assumes that your
19application requires the underlying hardware feature and filters the application
20from devices that do not offer it.</p>
21
22<p>To control filtering, always explicitly declare
23hardware features in <code>&lt;uses-feature&gt;</code> elements, rather than
24relying on Google Play to "discover" the requirements in
25<code>&lt;uses-permission&gt;</code> elements. Then, if you want to disable
26filtering for a particular feature, you can add a
27<code>android:required="false"</code> attribute to the
28<code>&lt;uses-feature&gt;</code> declaration.</p>
29
30<p>For a list of permissions that imply
31hardware features, see the documentation for the <a
32href="{@docRoot}guide/topics/manifest/uses-feature-element.html#permissions-features">
33<code>&lt;uses-feature&gt;</code></a> element.</p>
34</div>
35</div>
36
37<dt>syntax:</dt>
38<dd><pre class="stx">&lt;uses-permission android:<a href="#nm">name</a>="<i>string</i>"
39        android:<a href="#maxSdk">maxSdkVersion</a>="<i>integer</i>" /&gt;</pre></dd>
40
41<dt>contained in:</dt>
42<dd><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>
43
44<dt>description:</dt>
45<dd itemprop="description">Requests a permission that the application must be granted in
46order for it to operate correctly. Permissions are granted by the user when the
47application is installed (on devices running Android 5.1 and lower) or while the app is running (on devices running Android 6.0 and higher).
48
49<p>
50For more information on permissions, see the
51<a href="{@docRoot}guide/topics/manifest/manifest-intro.html#perms">Permissions</a></code>
52section in the introduction and the separate
53<a href="{@docRoot}guide/topics/security/permissions.html">System
54Permissions</a> API guide.
55A list of permissions defined by the base platform can be found at
56{@link android.Manifest.permission android.Manifest.permission}.
57
58<dt>attributes:</dt>
59<dd><dl class="attr">
60<dt><a name="nm"></a>{@code android:name}</dt>
61<dd>The name of the permission.  It can be a permission defined by the
62application with the <code><a href="{@docRoot}guide/topics/manifest/permission-element.html">&lt;permission&gt;</a></code>
63element, a permission defined by another application, or one of the
64standard system permissions (such as
65{@link android.Manifest.permission#CAMERA "android.permission.CAMERA"}
66or {@link android.Manifest.permission#READ_CONTACTS
67"android.permission.READ_CONTACTS"}).  As these examples show,
68a permission name typically includes the package name as a prefix.</dd>
69
70<dt><a name="maxSdk"></a>{@code android:maxSdkVersion}</dt>
71<dd>The highest API level at which this permission should be granted to your app.
72Setting this attribute is useful if the permission your app requires is no longer needed beginning
73at a certain API level.
74<p>For example, beginning with Android 4.4 (API level 19), it's no longer necessary for your app
75to request the {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission when your
76app wants to write to its own application-specific directories on external storage (the directories
77provided by {@link android.content.Context#getExternalFilesDir getExternalFilesDir()}). However,
78the permission <em>is required</em> for API level 18 and lower. So you can declare that this
79permission is needed only up to API level 18 with a declaration such as this:
80<pre>
81&lt;uses-permission
82     android:name="android.permission.WRITE_EXTERNAL_STORAGE"
83     android:maxSdkVersion="18" />
84</pre>
85<p>This way, beginning with API level 19, the system will no longer grant your app the
86{@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission.</p>
87<p>This attribute was added in API level 19.</p>
88</dd>
89
90</dl></dd>
91
92<!-- ##api level indication## -->
93<dt>introduced in:</dt>
94<dd>API Level 1</dd>
95
96<dt>see also:</dt>
97<dd>
98<ul>
99  <li><code><a href="{@docRoot}guide/topics/manifest/permission-element.html">&lt;permission&gt;</a></code></li>
100  <li><a href="uses-permission-sdk-23-element.html"
101      ><code>&lt;uses-permission-sdk-23&gt;</code></a></li>
102  <li><code><a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a></code></li>
103</ul>
104</dd>
105
106</dl>
107