Join Slack
Powered by
Does Anko offer a special mechanism to deal with r...
# anko
c
Christian Goldapp
10/08/2018, 12:35 PM
Does Anko offer a special mechanism to deal with requesting permissions at runtime? Implementing it the "regular way", as it would be done in pure Java, seems pretty clunky and un-Kotlin to me.
m
miha-x64
10/08/2018, 12:38 PM
I use this to fix ugly Android APIs like runtime permissions, starting activities for result, and more.
https://github.com/Miha-x64/Flawless
c
Christian Goldapp
10/08/2018, 12:41 PM
Thank you! I'll have a look at that.
a
Allan Wang
10/09/2018, 4:39 AM
Here is another solution that I built:
https://github.com/AllanWang/KAU/tree/dev/core/src/main/kotlin/ca/allanwang/kau/permissions
Example call:
https://github.com/AllanWang/KAU/blob/dev/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt#L36
If you want to implement it yourself, the idea is that you can pass a vararg of permission keys and register a callback. You can keep a weak reference to it and then handle the callbacks when you get a response. The problem here is that your permission requests will not stick if your activity reloads (which is why the response is tied to the activity anyways), but that is typically fine as the user can just request it again
3
Views
Open in Slack
Previous
Next