An easy to use open source library using in the kotlin
这是一个基于 Kotlin
的简单易用的权限申请库
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.LoveLifeEveryday:XPermissions:1.0.0'
}
XPermission.request(
this,
// 这里的权限可以是单个或者多个,权限之间用逗号『,』隔开即可
Manifest.permission.XXX1,
Manifest.permission.XXX2,
// allGranted 是一个 boolean 类型的变量,若为 true ,则所有权限申请通过
// deniedList 是一个 List 类型的变量,表示用户拒绝权限列表
) { allGranted, deniedList ->
if (allGranted) {
Toast.makeText(this, "All permissions are granted", Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(this, "You denied $deniedList", Toast.LENGTH_SHORT).show()
}
}
测试用的
Demo
为了方便读者们了解编写『请求框架』以及发布到 JitPack
的一系列流程,笔者特意写了一篇文章来阐述:
👤 许朋友爱玩
Github
: https://github.com/LoveLifeEveryday/- 个人博客:http://xcynice.xyz/
- 掘金:https://juejin.im/user/5e429bbc5188254967066d1b/posts
Give a ⭐️ if this project helped you!
求星星⭐️,求赞👍