Se7eN
10/12/2021, 4:52 PMPermissionUtils
that takes care of checking/requesting permissions:
object PermissionUtils {
fun checkPermissions(context: Context, permissions: List<String>, listener: PermissionListener) {
// uses a library that checks for permissions and calls listener.onPermissionsGranted() or listener.onPermissionsDenied()
}
}
Now, to use the new activity result API, I'd have to register the contracts in each activity, which doesn't sound good because I have many activities and all of them would look like this:
class MyActivity : AppCompatActivity {
val imageFromGallery = registerForActivityResult(RequestMultiplePermissions()) {
...
}
val takePicture = registerForActivityResult(RequestMultiplePermissions()) {
...
}
val shareImage = registerForActivityResult(RequestMultiplePermissions()) {
...
}
}
Is it possible to incorporate this logic into the checkPermissions()
function itself?Ian Lake
10/12/2021, 5:07 PMSe7eN
10/12/2021, 5:11 PMMyActivityObserver
?Se7eN
10/12/2021, 5:13 PMSe7eN
10/13/2021, 7:03 AMonRequestPermissionsResult
to handle the request code. Is it not deprecated?
If not, can I keep using that library in my app?Ian Lake
10/13/2021, 1:39 PM