Skip to content

A Permission Helper SDK to Request Permission Launcher with Kotlin in run time permissions for request permission launchers. and get its call back granted or not Granted

Notifications You must be signed in to change notification settings

dev-kami/XamiPermissionsUtils

Repository files navigation

XamiPermissionsUtils

A Permission Helper class to Request Permission Launcher with Kotlin in Android. A Utils Helper for the run time permissions for request permission launchers. and get its call back granted or not

  1. Add this SDK in your App gradle

SDK

implementation 'com.github.kami-kamran:XamiPermissionsUtils:0.0.2'

How to use inside Activity

    var permissionsUtil: PermissionsUtil? = null

permissionsUtil = PermissionsUtil.getInstance(this@MainActivity, this.activityResultRegistry)

    lifecycle.addObserver(permissionsUtil!!)
    
      private fun requestSMSPermission() {
   permissionsUtil?.let { permission ->
            permission.requestPermission(
               PermissionMsg = "App required Required Permission to continue",
              permission =   arrayOf(
                    android.Manifest.permission.READ_SMS,
                    android.Manifest.permission.RECEIVE_SMS
                ),
                showDialog = true,
                callBack = object : PermissionsUtil.PermissionsListenerCallback {
                    override fun onPermissionGranted() {
                        /* Perform action on Permission Granted*/
                    }
                    override fun onPermissionCancel() {
                      /* Perform action on Permission Cancel*/
                    }
                })
        }

}

##How to Use inside Fragment

  private fun requestPermission() {
        (activity as MainActivity).permissionsUtil?.let { permission ->
            permission.requestPermission(
               PermissionMsg = "App required Required Permission to continue",
              permission =   arrayOf(
                    android.Manifest.permission.READ_SMS,
                    android.Manifest.permission.RECEIVE_SMS
                ),
                showDialog = true,
                callBack = object : PermissionsUtil.PermissionsListenerCallback {
                    override fun onPermissionGranted() {
                        /* Perform action on Permission Granted*/
                    }
                    override fun onPermissionCancel() {
                      /* Perform action on Permission Cancel*/
                    }
                })
    }
}

About

A Permission Helper SDK to Request Permission Launcher with Kotlin in run time permissions for request permission launchers. and get its call back granted or not Granted

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages