dangerous

Leverage Kotlin API for Android runtime permissions

View the Project on GitHub hendraanggrian/dangerous

Travis CI Codecov Maven Central Nexus Snapshot Android SDK

Dangerous

Lightweight library to simplify the process of requesting permissions.

requirePermission(Manifest.permission.CAMERA)
camera.start()

// or

withPermission(Manifest.permission.CAMERA) { isGranted ->
    if (isGranted) {
        camera.start()
    }
}

Download

repositories {
    google()
    mavenCentral()
}
dependencies {
    compile 'com.hendraanggrian.appcompat:dangerous:0.1'
}

Usage

To force user open Settings app, provide the second DSL.

withPermission(Manifest.permission.CAMERA, { settingsIntent ->
    AlertDialog.Builder(this)
        .setTitle("Permission Denied")
        .setMessage("Need to be enabled manually.")
        .setPositiveButton("Go to Settings") { _, _ ->
            startActivity(settingsIntent)
        }
}) { isGranted ->
    if (isGranted) {
        camera.start()
    }
}