I am using EasyPermissions library in my project . It build successfully but got error at the run time. I am building my application in 28. I use the latest version and before that but still getting the same error.
I recommended to use below Android Run time Permission Library
implementation 'com.nabinbhandari.android:permissions:3.8'
First declare your permissions in the manifest.
like
Sample code: 1) Single Permission ()
Permissions.check(this, Manifest.permission.CALL_PHONE, null, new PermissionHandler() {
@Override
public void onGranted() {
// do your task.
}
});
2)Multiple permissions:
String[] permissions = {Manifest.permission.CAMERA,
Manifest.permission.WRITE_EXTERNAL_STORAGE};
Permissions.check(this/*context*/, permissions, null/*rationale*/, null/*options*/,
new PermissionHandler() {
@Override
public void onGranted() {
// do your task.
}
});
3)Customized permissions request:
String[] permissions = {Manifest.permission.ACCESS_FINE_LOCATION};
String rationale = "Please provide location permission so that you can ...";
Permissions.Options options = new Permissions.Options()
.setRationaleDialogTitle("Info")
.setSettingsDialogTitle("Warning");
Permissions.check(this/*context*/, permissions, rationale, options, new
PermissionHandler() {
@Override
public void onGranted() {
// do your task.
}
@Override
public void onDenied(Context context, ArrayList<String> deniedPermissions) {
// permission denied, block the feature.
}
});
Check this library: @github https://github.com/nabinbhandari/Android-Permissions
or check this answer for permission code https://stackoverflow.com/a/55452495/10758304