blob: e33c60833dca4d2b9bca370aacbedf66f01daf69 [file] [log] [blame]
Jan-Felix Schmakeit1cdebcd2015-05-23 04:34:44 +10001<?xml version="1.0" encoding="UTF-8"?>
2<!--
3 Copyright 2015 The Android Open Source Project
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17<sample>
18 <name>RuntimePermissions</name>
19 <group>System</group>
20 <package>com.example.android.system.runtimepermissions</package>
21
22 <minSdk>"MNC"</minSdk>
23 <targetSdkVersion>"MNC"</targetSdkVersion>
24 <compileSdkVersion>"android-MNC"</compileSdkVersion>
25
26
27 <dependency>com.android.support:appcompat-v7:21.+</dependency>
28
29 <strings>
30 <intro>
31 <![CDATA[
32 This sample shows runtime permissions available in the Android M and above.
33 Display the log to follow the execution.
34 If executed on an Android M device, an additional option to access contacts is shown.
35 ]]>
36 </intro>
37 </strings>
38
39 <template src="base"/>
40 <common src="logger"/>
41 <common src="activities"/>
42
43 <metadata>
Trevor Johns415e5ce2015-05-27 12:21:44 -070044 <status>DRAFT</status>
Jan-Felix Schmakeit1cdebcd2015-05-23 04:34:44 +100045 <categories>System</categories>
46 <technologies>Android</technologies>
47 <languages>Java</languages>
48 <solutions>Mobile</solutions>
49 <level>BEGINNER</level>
50 <icon>screenshots/big_icon.png</icon>
51 <screenshots>
52 <img>screenshots/screenshot-1.png</img>
53 <img>screenshots/screenshot-2.png</img>
54 </screenshots>
55 <api_refs>
56 <android>android.app.Activity</android>
57 <android>android.Manifest.permission</android>
58 </api_refs>
59
60 <description>
61<![CDATA[
62This sample shows runtime permissions available in the Android M and above.
63It shows how to check and request permissions at runtime and how to declare permissions for M-devices
64only.
65]]>
66 </description>
67
68 <intro>
69<![CDATA[
70Android M introduced runtime permissions. Applications targeting M and above need to request their
71permissions at runtime.
72All permissions still need to be declared in the AndroidManifest. However, when accessing APIs that
73require a permission, the Activity or Fragment has to verify that the permission has been granted
74or request the missing permissions. Permissions are checked through
75Activity#requestPermissions(String[], int) and Fragment#requestPermissions(String[], int).
76Permission requests are sent through Activity#requestPermissions(String[]), and the response
77received in the callback Activity#onRequestPermissionsResult(int, permissions[], int[]).
Jan-Felix Schmakeit493cc172015-06-30 14:20:09 +100078Applications can provide an additional rational for the use of permissions after calling
79Activity#shouldShowRequestPermissionRationale(String). This call will return true if the
80application should provide the user with more context on why the requested permissions is needed,
81for example if the permission request has been denied before.
Jan-Felix Schmakeit1cdebcd2015-05-23 04:34:44 +100082
83If an application targets an SDK below M, all permissions are granted at runtime and are available
84when the application is running. However, if permissions have been turned off in the system settings
85for an application targeting an SDK below M, the API will return empty or no data.
86]]>
87 </intro>
88 </metadata>
89</sample>