• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

.google/23-Nov-2023-269

app/23-Nov-2023-1,254638

gradle/wrapper/23-Nov-2023-76

README.mdD23-Nov-20233.5 KiB8560

build.gradleD23-Nov-2023544 2622

gradle.propertiesD23-Nov-2023730 1813

gradlewD23-Nov-20234.9 KiB161120

gradlew.batD23-Nov-20232.3 KiB9166

settings.gradleD23-Nov-202315 21

README.md

1
2Android RuntimePermissions Sample (Kotlin)
3==========================================
4
5This sample shows runtime permissions available in Android M and above.
6It shows how to check and request permissions at runtime, handle backwards compatibility using the
7support library and how to declare optional permissions for M-devices only.
8
9Introduction
10------------
11
12Android M introduced runtime permissions. Applications targeting M and above need to request their
13permissions at runtime.
14
15All permissions still need to be declared in the AndroidManifest. However, when accessing APIs that
16require a permission, the Activity or Fragment has to verify that the permission has been granted
17or request the missing permissions using calls through the support library.
18
19Permissions are checked through `ActivityCompat#checkSelfPermission(Context, String)` or
20ContextCompat#checkSelfPermission(Context, String).
21
22Permission are requested through `ActivityCompat#requestPermissions(Activity, String[], int)`, and
23the response received in a callback to
24`ActivityCompat.OnRequestPermissionsResultCallback#onRequestPermissionsResult(int, String[], int[])`.
25
26Applications can provide an additional rational for the use of permissions after calling
27`ActivityCompat#shouldShowRequestPermissionRationale(Activity,String)`. This call will return true
28if the application should provide the user with more context on why the requested permissions is
29needed, for example if the permission request has been denied before.
30
31If an application targets an SDK below M, all permissions are granted at runtime and are available
32when the application is running. The support library calls handle these checks appropriately.
33However, if permissions have been turned off in the system settings
34for an application targeting an SDK below M, the API will return empty or no data.
35
36Pre-requisites
37--------------
38
39- Android SDK 26
40- Android Support Repository
41
42Screenshots
43-------------
44
45<img src="screenshots/screenshot-1.png" height="400" alt="Screenshot"/>
46<img src="screenshots/screenshot-2.png" height="400" alt="Screenshot"/>
47
48Getting Started
49---------------
50
51This sample uses the Gradle build system. To build this project, use the
52"gradlew build" command or use "Import Project" in Android Studio.
53
54Support
55-------
56
57- Google+ Community: https://plus.google.com/communities/105153134372062985968
58- Stack Overflow: http://stackoverflow.com/questions/tagged/android
59
60If you've found an error in this sample, please file an issue:
61https://github.com/googlesamples/android-RuntimePermissions
62
63Patches are encouraged, and may be submitted by forking this project and
64submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
65
66License
67-------
68
69Copyright 2017 The Android Open Source Project, Inc.
70
71Licensed to the Apache Software Foundation (ASF) under one or more contributor
72license agreements.  See the NOTICE file distributed with this work for
73additional information regarding copyright ownership.  The ASF licenses this
74file to you under the Apache License, Version 2.0 (the "License"); you may not
75use this file except in compliance with the License.  You may obtain a copy of
76the License at
77
78http://www.apache.org/licenses/LICENSE-2.0
79
80Unless required by applicable law or agreed to in writing, software
81distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
82WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
83License for the specific language governing permissions and limitations under
84the License.
85