Giter VIP home page Giter VIP logo

gmpermission's Introduction

GmPermission

It is easy to handle the runtime permission

How to build

Add Jitpack.io to your project level build.gradle file

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

Add the dependency

dependencies {
    implementation 'com.github.goutham106:runtimepermission:0.2'
	}

How to use

Create a GmPermissionManager object

 val permissionManager = GmPermissionManager.builder()
            .with(this)
            .requestCode(REQUEST_CODE)
            .neededPermissions(<IMPLEMENT_NEEDED PERMISSIONS IN STRING ARRAY>)
            .setPermissionListner(object : PermissionListener {
                override fun onPermissionsGranted(requestCode: Int, acceptedPermission: String) {   
			<ON PERMISSION GRANTED>
                }

                override fun showGrantDialog(grantPermissionTo: String): Boolean {
			<IMPLEMENT Snackbar/Dialog to show when permission denied>
                    return super.showGrantDialog(grantPermissionTo)
                }

                override fun showRationalDialog(requestCode: Int, deniedPermission: String): Boolean {
			<IMPLEMENT Snackbar/Dialog to show when permission denied with Don't ask again,Usually goto setting menu>
			
                    return super.showRationalDialog(requestCode, deniedPermission)
                }
            })
            .build()
                

override

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        permissionManager?.onRequestPermissionsResult(requestCode, permissions, grantResults)
    }

and when you want to ask for the permission just call

permissionManager?.requestPermissions()

Detailed full sample project is included. Check MainActivity for full implemetation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.