3.5 Permissions
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />How can we request permissions?
<manifest xlmns:android...>
...
<uses-permission android:name=”android.permission.PERMISSION_NAME”/>
<application ...
</manifest>
private lateinit var requestPermissionLauncher: ActivityResultLauncher<String>
override fun onCreate(savedInstanceState: Bundle?) {
...
requestPermissionLauncher =
registerForActivityResult(ActivityResultContracts.RequestPermission()
) { isGranted: Boolean ->
if (isGranted) {
// Permission is granted. Continue the action or workflow in your
// app.
} else {
// Explain to the user that the feature is unavailable because the
// features requires a permission that the user has denied. At the
// same time, respect the user's decision. Don't link to system
// settings in an effort to convince the user to change their
// decision.
}
}
...
}How does this work if we want to request multiple permissions at once?
Accompanist - Simplifying Permissions
Installation
Setup
Checking and Requesting Permissions
Requesting Permissions Flow
Last updated
Was this helpful?