Nammu
Nammu copied to clipboard
Differnciate between Permission asking 1st time or never ask again.
How to differentiate between the permission that I am calling is first time or user have selected on the never asked again. In sample you have mentioned this thing.
@OnClick(R.id.buttonLocation) public void clickButtLocation() { if (Nammu.checkPermission(Manifest.permission.ACCESS_FINE_LOCATION)) { boolean hasAccess = Tools.accessLocation(this); Toast.makeText(this, "Access granted fine= " + hasAccess, Toast.LENGTH_SHORT).show(); } else { if (Nammu.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION)) { //User already refused to give us this permission or removed it //Now he/she can mark "never ask again" (sic!) Snackbar.make(mLayout, "Here we explain user why we need to know his/her location.", Snackbar.LENGTH_INDEFINITE).setAction("OK", new View.OnClickListener() { @Override public void onClick(View view) { Nammu.askForPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION, permissionLocationCallback); } }).show(); } else { //First time asking for permission // or phone doesn't offer permission // or user marked "never ask again" Nammu.askForPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION, permissionLocationCallback); } } }
Here in comments you have mentioned First time asking permission or user marked "never ask again."
I want to know when user selected never asked again and proceed further
Draft:
- we keep information if user (at least once) refused to give permission
- if user granted permission - we remove above info
- we need to update it in Nammu.init() - monitor for background changes.
Probably I need to draw for myself a small flow chart to avoid any corner cases in terms of false positives.