{"id":26784859,"url":"https://github.com/sagar-viradiya/eazypermissions","last_synced_at":"2025-04-19T17:06:51.545Z","repository":{"id":44745887,"uuid":"182243498","full_name":"sagar-viradiya/eazypermissions","owner":"sagar-viradiya","description":"Android library to handle runtime permission through Kotlin coroutines and Livedata.","archived":false,"fork":false,"pushed_at":"2020-10-06T08:13:23.000Z","size":953,"stargazers_count":252,"open_issues_count":6,"forks_count":24,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-05-02T00:54:09.681Z","etag":null,"topics":["android","android-library","coroutines","hacktoberfest","kotlin","kotlin-dsl","livedata","runtime-permissions"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sagar-viradiya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["sagar-viradiya"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-04-19T09:55:19.000Z","updated_at":"2023-11-11T15:06:51.000Z","dependencies_parsed_at":"2022-09-24T08:30:29.412Z","dependency_job_id":null,"html_url":"https://github.com/sagar-viradiya/eazypermissions","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagar-viradiya%2Feazypermissions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagar-viradiya%2Feazypermissions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagar-viradiya%2Feazypermissions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagar-viradiya%2Feazypermissions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sagar-viradiya","download_url":"https://codeload.github.com/sagar-viradiya/eazypermissions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246174178,"owners_count":20735406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","coroutines","hacktoberfest","kotlin","kotlin-dsl","livedata","runtime-permissions"],"created_at":"2025-03-29T10:32:44.503Z","updated_at":"2025-03-29T10:33:10.319Z","avatar_url":"https://github.com/sagar-viradiya.png","language":"Kotlin","funding_links":["https://github.com/sponsors/sagar-viradiya"],"categories":[],"sub_categories":[],"readme":"# Eazy Runtime Permission\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/sagar-viradiya/eazypermissions/blob/master/LICENSE) ![Pull request](https://github.com/sagar-viradiya/eazypermissions/workflows/Pull%20request/badge.svg) [![API](https://img.shields.io/badge/API-20%2B-orange.svg?style=flat)](https://android-arsenal.com/api?level=20) [![ktlint](https://img.shields.io/badge/code%20style-%E2%9D%A4-FF4081.svg)](https://ktlint.github.io/) [![Android Arsenal]( https://img.shields.io/badge/Android%20Arsenal-eazypermissions-green.svg?style=flat )]( https://android-arsenal.com/details/1/7799 )\n\nA lightweight Android library which wraps boilerplate code of runtime permission and allows you to request permissions \n1. from coroutines. (No callbacks yay :tada:)\n2. request and observe permissions through LiveData.\n3. through clean and concise Kotlin DSL.\n\n\u003e From release `2.0.0` onwards library is migrated to AndroidX. If you are still using support library and haven't migrated to AndroidX then check out non-androidX version of the [library](https://github.com/sagar-viradiya/eazypermissions/tree/master-nonandroidx).\n\n## Including in your project\nEazy permissions is available in the Jcenter and divided into three modules so that based on your need you can include either coroutines or livedata or Kotlin DSL support in your project\n\n```groovy\n//For coroutines\nimplementation 'com.sagar:coroutinespermission:[latest_version]'\n\n//For LiveData\nimplementation 'com.sagar:livedatapermission:[latest_version]'\n\n//For Kotlin DSL\nimplementation 'com.sagar:dslpermission:[latest_version]'\n```\n- `latest_version` for coroutines - [ ![Download](https://api.bintray.com/packages/sagar-viradiya/eazypermissions/coroutinespermission/images/download.svg) ](https://bintray.com/sagar-viradiya/eazypermissions/coroutinespermission/_latestVersion)\n- `latest_version` for livedata - [ ![Download](https://api.bintray.com/packages/sagar-viradiya/eazypermissions/livedatapermission/images/download.svg) ](https://bintray.com/sagar-viradiya/eazypermissions/livedatapermission/_latestVersion)\n- `latest_version` for Kotlin DSL - [ ![Download](https://api.bintray.com/packages/sagar-viradiya/eazypermissions/dslpermission/images/download.svg) ](https://bintray.com/sagar-viradiya/eazypermissions/dslpermission/_latestVersion)\n\n## Coroutines support\nThis is how you would request permission within coroutines.\n\n```kotlin\n.\n.\n.\nlaunch {\n    //CoroutineScope\n\n    val permissionResult = PermissionManager.requestPermissions(           //Suspends the coroutine\n                            this@Fragment,                                  \n                            REQUEST_ID,\n                            Manifest.permission.ACCESS_FINE_LOCATION,\n                            Manifest.permission.READ_CONTACTS,\n                            Manifest.permission.CAMERA\n                        )\n                        \n    //Resume coroutine once result is ready\n    when(permissionResult) {\n        is PermissionResult.PermissionGranted -\u003e {\n            //Add your logic here after user grants permission(s)\n        }\n        is PermissionResult.PermissionDenied -\u003e {\n            //Add your logic to handle permission denial\n        }\n        is PermissionResult.PermissionDeniedPermanently -\u003e {\n            //Add your logic here if user denied permission(s) permanently.\n            //Ideally you should ask user to manually go to settings and enable permission(s)\n        }\n        is PermissionResult.ShowRational -\u003e {\n            //If user denied permission frequently then she/he is not clear about why you are asking this permission.\n            //This is your chance to explain them why you need permission.\n        }\n    }\n\n}\n```\n\nRead more about coroutines support [*here*](coroutinespermission)\n\n## Kotlin DSL support\nThis is how you would request permission through clean and concise Kotlin DSL.\n\n```kotlin\nrequestPermissions(\n    Manifest.permission.ACCESS_FINE_LOCATION,\n    Manifest.permission.READ_CONTACTS,\n    Manifest.permission.CAMERA\n) {\n    requestCode = 4\n    resultCallback = {\n        when(this) {\n            is PermissionResult.PermissionGranted -\u003e {\n                //Add your logic here after user grants permission(s)\n            }\n            is PermissionResult.PermissionDenied -\u003e {\n                //Add your logic to handle permission denial\n            }\n            is PermissionResult.PermissionDeniedPermanently -\u003e {\n                //Add your logic here if user denied permission(s) permanently.\n                //Ideally you should ask user to manually go to settings and enable permission(s)\n            }\n            is PermissionResult.ShowRational -\u003e {\n                //If user denied permission frequently then she/he is not clear about why you are asking this permission.\n                //This is your chance to explain them why you need permission.\n            }\n        }\n    }\n}\n```\n\nRead more about Kotlin DSL support [*here*](dslpermission)\n\n## LiveData support\nThis is how you would request permission within Acivity/Fragment.\n\n```kotlin\nPermissionManager.requestPermissions(\n                this,\n                REQUEST_ID,\n                Manifest.permission.ACCESS_FINE_LOCATION,\n                Manifest.permission.READ_CONTACTS\n            )\n```\n\nObserving permission result requires your Actvity/Fragment to implement [`PermissionObserver`](https://github.com/sagar-viradiya/eazypermissions/blob/e1a36d5fb3ad487ac22da9b18e9b4c848cfcb74c/livedatapermission/src/main/java/com/eazypermissions/livedatapermission/PermissionManager.kt#L115)\n\n```kotlin\n/**\n * Interface definition for a callback to get [LiveData] of [PermissionResult]\n *\n * Implement this interface to get [LiveData] for observing permission request result.\n */\ninterface PermissionObserver {\n    fun setupObserver(permissionResultLiveData: LiveData\u003cPermissionResult\u003e)\n}\n```\nJust as you would observe other LiveData you can observe LiveData\u003c[`PermissionResult`](common/src/main/java/com/eazypermissions/common/model/PermissionResult.kt)\u003e as follow.\n```kotlin\noverride fun setupObserver(permissionResultLiveData: LiveData\u003cPermissionResult\u003e) {\n    permissionResultLiveData.observe(this, Observer\u003cPermissionResult\u003e {\n        when (it) {\n            is PermissionResult.PermissionGranted -\u003e {\n                if (it.requestId == REQUEST_ID) {\n                    //Add your logic here after user grants permission(s)\n                }\n            }\n            is PermissionResult.PermissionDenied -\u003e {\n                if (it.requestId == REQUEST_ID) {\n                    //Add your logic to handle permission denial\n                }\n            }\n            is PermissionResult.PermissionDeniedPermanently -\u003e {\n                if (it.requestId == REQUEST_ID) {\n                    //Add your logic here if user denied permission(s) permanently.\n                    //Ideally you should ask user to manually go to settings and enable permission(s)\n                }\n            }\n            is PermissionResult.ShowRational -\u003e {\n                if (it.requestId == REQUEST_ID) {\n                    //If user denied permission frequently then she/he is not clear about why you are asking this permission.\n                    //This is your chance to explain them why you need permission.\n                }\n            }\n        }\n    })\n}\n```\nRead more about LiveData support [*here*](livedatapermission)\n\n## Contributing\nHave suggestions for improvements and want to contribute? or Found any issues?  \nHead over to [Contribution guidelines](CONTRIBUTING.md) to know more about contributing to this library.\n\n## Screenshots of sample\n![sc1](screenshots/SS1.png) ![sc2](screenshots/SS2.png)   \n![sc1](screenshots/SS3.png) ![sc2](screenshots/SS4.png)\n\n# License\n\n```\nCopyright 2019 Sagar Viradiya\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagar-viradiya%2Feazypermissions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsagar-viradiya%2Feazypermissions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagar-viradiya%2Feazypermissions/lists"}