Requesting permission from the user
Our app might want to implement certain features that Google deems dangerous. This usually means access to those features could risk the user’s privacy. For example, some permissions may allow you to read users’ messages or determine their current location.
Depending on the required permission and the target Android API level we are developing, we may need to request that permission from the user. If the device is running on Android 6 (Marshmallow, API level 23), and the target API of our app is 23 or higher (it almost certainly will be, as most devices by now will run newer versions of Android), there will be no alert for the user about any permissions requested by the app at install time. Instead, our app must ask the user to grant those permissions at runtime.
When we request permission, the user sees a dialog like the one shown in Figure 7.1.
Figure 7.1 – Permission dialog for device location...