Easy way to handle all permissions

Overview

BestPermissionUtil

You can read the story from here https://hamurcuabi.medium.com/permissions-with-the-easiest-way-9c466ab1b2c1

Prerequisites

Add this in your root build.gradle file (not your module build.gradle file):

allprojects {
	repositories {
		...
		maven { url "https://jitpack.io" }
	}
}

Dependency

Add this to your module's build.gradle file (make sure the version matches the JitPack badge above):

dependencies {
	...
	 implementation 'com.github.hamurcuabi:BestPermissionUtil:1.0.3'
}

Usage

private val cameraPermission = registerPermission {
    onCameraPermissionResult(it)
}

private val storagePermission = registerPermission {
    onStoragePermissionResult(it)
}

 private fun onStoragePermissionResult(state: PermissionUtil.PermissionState) {
    when (state) {
        Denied -> {
            TODO()
        }
        Granted -> {
            TODO()
        }
        PermanentlyDenied -> {
            TODO()
        }
    }
}

private fun onCameraPermissionResult(state: PermissionUtil.PermissionState) {
    when (state) {
        Denied -> {
            TODO()
        }
        Granted -> {
            TODO()
        }
        PermanentlyDenied -> {
            TODO()
        }
    }
}

 cameraPermission.launchSinglePermission(android.Manifest.permission.CAMERA)

    storagePermission.launchMultiplePermission(
        arrayOf(
            android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
            android.Manifest.permission.READ_EXTERNAL_STORAGE
        )
    )
You might also like...
Basic-Android-Project - A Basic Android Project with proper structure and all necessary dependencies

Basic-Android-Project A Basic Android Project with proper structure and all nece

Backend aio - A project made to help all newbie programmers that are approaching backend development

BackendAIO A ktor based ready to use backend BackendAIO is a project made to hel

Add page & limit as GET parameter to get all titans data in a paginated format

Add page & limit as GET parameter to get all titans data in a paginated format (default values : page=1 and limit=3). Here the page param is the page number which you require and limit is the maximum number of items per page. Sample Request :

Bring together all of the remarkable Computer Graphics Algorithms in one place 🚀
Bring together all of the remarkable Computer Graphics Algorithms in one place 🚀

Compose Computer Graphics Playground 🚀 "There was an idea to bring together all of the remarkable Computer Graphics Algorithms in one place. And keep

The app is composed of 2 screens, first is the profile screen, it has the user_name and address pinned at the top and then it lists all of this user’s albums.
The app is composed of 2 screens, first is the profile screen, it has the user_name and address pinned at the top and then it lists all of this user’s albums.

The app is composed of 2 screens, first is the profile screen, it has the user_name and address pinned at the top and then it lists all of this user’s albums. When you press on any album it navigates to the second screen which is an album details screen that contains list of the images in an recyclerview grid. Also you have search bar that you can filter within the photos album by the image title.

SeatBookView is an Android Studio Library that helps to make it easier to create Bus, Train, Cinema Theater Seat UI and all functionalities are given.
SeatBookView is an Android Studio Library that helps to make it easier to create Bus, Train, Cinema Theater Seat UI and all functionalities are given.

SeatBookView SeatBookView is an Android Studio Library that helps to make it easier to create Bus 🚍 , Train 🚉 , Cinema Theater Seat UI and all funct

Build with Jetpack Compose & all modern techniques and architecture of android app development
Build with Jetpack Compose & all modern techniques and architecture of android app development

IMDB Movie App Build with Jetpack Compose & all modern techniques and architecture of android app development ScreenShots 🛠 Built With 🛠 Kotlin - Fi

🔥The Android Startup library provides a straightforward, performant way to initialize components at the application startup. Both library developers and app developers can use Android Startup to streamline startup sequences and explicitly set the order of initialization.
🔥The Android Startup library provides a straightforward, performant way to initialize components at the application startup. Both library developers and app developers can use Android Startup to streamline startup sequences and explicitly set the order of initialization.

🔥The Android Startup library provides a straightforward, performant way to initialize components at the application startup. Both library developers and app developers can use Android Startup to streamline startup sequences and explicitly set the order of initialization.

Cago provides you way to do complex calculations on your device.

Cago Do your calculations easier. Cago provides you way to do complex calculations on your device. You can build functions that fit your goals by your

Comments
  • permanently denied on location request

    permanently denied on location request

    Hi! good job for you library but i have some problems. When i ask access fine and coarse location, when i choose accept permission only when i m using the apps the result state is permanently denied....... Do you have an idea?

    opened by cleawrence 2
Releases(1.0.3)
Owner
Emre Hamurcu
Senior Android Developer
Emre Hamurcu
Project created in order to handle account management

Account Service App Aplicação responsável em receber dados de uma conta, validá-los e retornar mensagem de sucesso ou erro. Tecnologias utilizadas - L

Rafael Alberto 0 Dec 14, 2021
🍣✨ Simple Ktor server to handle GitHub -> YouTrack, usually for YouTrack Standalone.

?? sushi Simple Ktor server to handle GitHub Issues to YouTrack, usually for YouTrack Standalone. Why? There is not really a definite way to handle Gi

Noelware 2 Nov 11, 2021
CovidTracker traces all the covid-19 cases all over the world.

CovidTracker Crona Tracker trace india covid-19 cases upto district level and can trace other countries cases too. It can also traces user's current l

Anuraj Jain 6 May 22, 2021
Create libraries for all types of Kotlin projects: android, JVM, Multiplatform, Gradle plugins, and so on.

JavierSC Kotlin template Create libraries for all types of Kotlin projects: android, JVM, Multiplatform, Gradle plugins, and so on. Features Easy to p

Javier Segovia Córdoba 2 Dec 14, 2022
Almost all modern mobile consumer apps are constructed from the same 4 components

?? Why? Almost all modern mobile consumer apps are constructed from the same 4 components. A component to communicate to the backend server A way to o

AT 0 Nov 10, 2021
Advent of Code 2021 in Kotlin, solved by myself. Focus on code readability. With GitHub Actions all puzzles are executed and their solutions printed

Advent of Code 2021 in Kotlin Focus on Code Readability. With CI Solution Printing. Welcome to the Advent of Code1 Kotlin project created by michaeltr

Michael Troger 1 Dec 12, 2021
Trace all binder-funcion calls on android-platform

BinderHackDemo trace all binder-funcion calls on android-platform 该demo展示了如何使用libbinderhack.so模块,trace-app自身进程binder调用情况 您可以通过该次提交,查看如何使用libbinderhack

null 4 Dec 25, 2021
One app for all women that covers everything from safety to health and more. 👩💪

sampoorna Sampoorna is a one-in-all solution concept revolving around the women who fight one on one with various problems. With it's features encapsu

Open Lake 17 Dec 6, 2022