处理动态权限兼容问题,简化使用步骤。
I strongly recommend https://jitpack.io
repositories {
// ...
maven { url "https://jitpack.io" }
}
dependencies {
compile 'com.github.xiaosw:AppCompatPermission:1.0.0'
}
AppCompatPermission.checkAndRequestPermission(requestCode, object : OnPermissionListener {
override fun onGranted(requestCode: Int, grantedPermissions: Array<out String>) {
}
}, permissions)
AppCompatPermission.checkAndRequestPermission(reqeustCode, new OnPermissionListener() {
@Override
public void onGranted(int reqeustCode, @NotNull String[] granteds) {
}
@Override
public void onDenied(int reqeustCode, List<String> denieds) {
}
@Override
public void onNeverDenied(int reqeustCode, List<String> derverDenieds) {
}
}, permissions);
如果设备多个项目引用 AppCompatPermission 导致安装失败,可使用以下配置解决:
<provider
android:authorities="package.internal.provider.PermissionInitProvider"
android:name="com.xiaosw.permission.provider.PermissionInitProvider"
tools:replace="android:authorities"/>