A set of Android-UI components to make it easier to request permission in a user friendly way.
A jetpack compose module to easy request background location permission in a intuitive way.
The library is available via MavenCentral:
allprojects {
repositories {
// ...
mavenCentral()
}
}
Add it to your module dependencies:
dependencies {
implementation("se.warting.permissionsui:permissionsui:<latest_version>")
}
Snapshots of the development version are available in Sonatype's snapshots repository.
allprojects {
repositories {
// ...
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
}
All you need to do is to call LocationInBackgroundTutorialView
:
LocationInBackgroundTutorialView() {
// Permissions granted
}
Example:
import se.warting.permissionsui.backgroundlocation.LocationInBackgroundTutorialView
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
BackgroundLocationPermissionRationaleTheme {
Surface(color = MaterialTheme.colors.background) {
LocationInBackgroundTutorialView() {
// Permissions granted
}
}
}
}
}
}
If you are not using compose in your app you can use PermissionsUiContracts.RequestBackgroundLocation
See: kotlin sample or java sample
For a full implementation see: Full sample
This Library adds the following permissions to your app:
- android.permission.ACCESS_COARSE_LOCATION
- android.permission.ACCESS_FINE_LOCATION
- android.permission.ACCESS_BACKGROUND_LOCATION
SDK | Happy case | Rationale case | Worst case |
---|---|---|---|
10 | |||
12 |