就那么简单 源码 https://github.com/cczhr/EPermission
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
requestPermissions()
}
@EPermission(true)//传 ture 会自动申请权限和弹出拒绝权限提示框
fun requestPermissions() {
}
/* @EPermission//只负责申请权限
fun requestPermissions() {
}
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if (requestCode == EPermission.REQUEST_CODE) {
//自己处理权限回调
}
}*/
}
1
AoEiuV020 2021-05-08 14:53:27 +08:00
packageManager.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS).requestedPermissions?.takeIf {
it.isNotEmpty() }?.let { ActivityCompat.requestPermissions(this, it, 1) } |
4
Helsing 2021-05-08 16:41:42 +08:00 via iPhone
RxPermission 了解一下🐶
|