-
public final class PermissionsManager
Helper class to manage app permissions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
PermissionsManager.Companion
-
Constructor Summary
Constructors Constructor Description PermissionsManager()
-
Method Summary
Modifier and Type Method Description final Unit
registerLocationPermissionsListener(ComponentActivity componentActivity, Function1<Map<String, Boolean>, Unit> onAllowed, Function1<Map<String, Boolean>, Unit> onDenied)
Registers a listener for location permissions requests. final Unit
registerLocationPermissionsListener(Fragment fragment, Function1<Map<String, Boolean>, Unit> onAllowed, Function1<Map<String, Boolean>, Unit> onDenied)
Registers a listener for location permissions requests. final Unit
requestLocationPermissions()
Launches intent to ask user for location permissions, see locationPermissions. final Unit
registerBluetoothPermissionsListener(ComponentActivity componentActivity, Function1<Map<String, Boolean>, Unit> onAllowed, Function1<Map<String, Boolean>, Unit> onDenied)
Registers a listener for bluetooth permissions requests. final Unit
registerBluetoothPermissionsListener(Fragment fragment, Function1<Map<String, Boolean>, Unit> onAllowed, Function1<Map<String, Boolean>, Unit> onDenied)
Registers a listener for bluetooth permissions requests. final Unit
requestBluetoothPermissions()
Launches intent to ask user for bluetooth permissions, see bluetoothPermissions. final Unit
onDestroy()
Unregisters all listeners and destroys all related instances. -
-
Method Detail
-
registerLocationPermissionsListener
final Unit registerLocationPermissionsListener(ComponentActivity componentActivity, Function1<Map<String, Boolean>, Unit> onAllowed, Function1<Map<String, Boolean>, Unit> onDenied)
Registers a listener for location permissions requests.
This must only be called once.
Recommended calling this method in your activity's onCreate method.
- Parameters:
componentActivity
- ComponentActivity instance.onAllowed
- Callback when grants all permissions.onDenied
- Callback when denies all or at least one permission.
-
registerLocationPermissionsListener
final Unit registerLocationPermissionsListener(Fragment fragment, Function1<Map<String, Boolean>, Unit> onAllowed, Function1<Map<String, Boolean>, Unit> onDenied)
Registers a listener for location permissions requests.
This must only be called once.
Recommended calling this method in your fragment's onCreateView method.
- Parameters:
fragment
- Fragment instance.onAllowed
- Callback when grants all permissions.onDenied
- Callback when denies all or at least one permission.
-
requestLocationPermissions
final Unit requestLocationPermissions()
Launches intent to ask user for location permissions, see locationPermissions.
This will open a permissions' dialog for each permission requested.
-
registerBluetoothPermissionsListener
final Unit registerBluetoothPermissionsListener(ComponentActivity componentActivity, Function1<Map<String, Boolean>, Unit> onAllowed, Function1<Map<String, Boolean>, Unit> onDenied)
Registers a listener for bluetooth permissions requests.
This must only be called once.
Recommended calling this method in your activity's onCreate method.
- Parameters:
componentActivity
- ComponentActivity instance.onAllowed
- Callback when grants all permissions.onDenied
- Callback when denies all or at least one permission.
-
registerBluetoothPermissionsListener
final Unit registerBluetoothPermissionsListener(Fragment fragment, Function1<Map<String, Boolean>, Unit> onAllowed, Function1<Map<String, Boolean>, Unit> onDenied)
Registers a listener for bluetooth permissions requests.
This must only be called once.
Recommended calling this method in your fragment's onCreateView method.
- Parameters:
fragment
- Fragment instance.onAllowed
- Callback when grants all permissions.onDenied
- Callback when denies all or at least one permission.
-
requestBluetoothPermissions
final Unit requestBluetoothPermissions()
Launches intent to ask user for bluetooth permissions, see bluetoothPermissions.
This will open a permissions' dialog for each permission requested.
-
-
-
-