How to Handle Denied Permissions Android M (EasyPermissions)
android, android-permissions, java, permissions
Solution
Check this link.
Here you have to implement the EasyPermissions.PermissionCallbacks with this you will be provided to add methods which will be onRequestPermissionsResult, onPermissionsGranted, onPermissionsDenied. Then in onPermissionsDenied you can handle your Denial status. Try it and let me know if it worked for you.
Problem
I'm using EasyPermissions to check if certain permissions have been granted in my android and and requesting them if not. Cool library, works great but I've still not gotten to figuring out how to handle if some permissions where denied. so basically you run a code like this on create to check ``` if (EasyPermissions.hasPermissions(Splash.this, perms )) { TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); String IMEI = telephonyManager.getDeviceId(); String SimSimSerial = telephonyManager.getSimSerialNumber(); Toast.makeText(Splash.this, "IMEI: " + IMEI + " SimSerial: " + SimSimSerial, Toast.LENGTH_SHORT).show(); } else { EasyPermissions.requestPermissions(Splash.this, "Without these permissions, the app is unable to successfully complete authentication. Please allow us to access your device so that we can better serve you. " ,PERMS_REQUEST_CODE, perms ); } ``` code breakdown: if permissions exist, continue else request which is fine. My question is what if during request someone click on the never ask button. The guys at EasyPermissions have a function for that its ``` EasyPermissions.somePermissionPermanentlyDenied(Splash.this, permsList) ``` My dilemma is where to call this function as the request permissions method doesnt returns nothing (void). I tried something like ``` if (EasyPermissions.hasPermissions(Splash.this, perms )) {... } else if (EasyPermissions.somePermissionPermanentlyDenied(Splash.this, permsList)) { } else { EasyPermissions.requestPermissions(Splash.this, "Without these permissions, the app is unable to successfully complete authentication. Please allow us to access your device so that we can better serve you. " ,PERMS_REQUEST_CODE, perms ); } ``` but it always run the permissions denied one on start and not when a user actually click the never button in runtime. Any help is appreciated thanks.. link to EasyPermissions https://github.com/googlesamples/easypermissions