Even though the Runtime permission model was released back in Android 6.0 (API 23), this topic still receives many queries. Since it's basically a requirement for all future apps, you'll likely need to implement this in Kotlin as well. Take a look at the previous recipe (see links below) for information on the APIs and this recipe for the Kotlin code.
Create a new project in Android Studio and call it KotlinRuntimePermission
. Use the default Phone & Tablet
option, select Empty Activity
when prompted for Activity Type
, and remember to check the Include Kotlin support
checkbox.
The sample source code sets the minimum API to 23, but this is not required. If your compileSdkVersion
is API 23 or above, the compiler will flag your code for the new security model.