ParkSangGwon / TedPermission

Easy check permission library for Android Marshmallow
1.74k stars 239 forks source link

Ability to unregister listener #49

Closed TurhanOz closed 7 years ago

TurhanOz commented 7 years ago

Is there any "proper" mecanism offered by the API to unregister the listener (usefull when dealing with lifecycle). Cheers

ParkSangGwon commented 7 years ago

Can you tell me some example case?

TurhanOz commented 7 years ago

Let's say you're igniting a permission request during the onStart() of your activity new TedPermission(context) .setPermissionListener(listener) .setDeniedMessage("whatever") .setPermissions(Manifest.permission.READ_CONTACTS) .check();

The listener will be triggered as soon as the permission is granted/denied even though your activity goes onStop(). In my case, the listener should process operations only when activity is visible, and I have no way to unregister the listener (unless registering an empty one when going to onStop ? which is still a workaround)

Any suggestion on that ? Cheers

ParkSangGwon commented 7 years ago

@TurhanOz Why do you use Tedpermission in onStart()? (not onCreate()) I recommend onCreate().