Skip to content

Permissions utils

If your are dealing with app permissions, turning on and off location and bluetooth, flight-mode and so on, maybe the following utilities can help you when implementing a UX.

For example, before invoking our permissions UIs, you should check for permissions/services status.

PermissionsUtils class, located in com.nearit.ui_bindings.utils package expose some useful static methods:

PermissionsUtils.checkLocationPermission(context: Context)
PermissionsUtils.checkLocationPermission(Context context)

returns true if permission (runtime permission on devices with API 23+) is granted

PermissionsUtils.checkLocationServices(context: Context)
PermissionsUtils.checkLocationServices(Context context)

returns true if location services are available

PermissionsUtils.checkBluetooth(context: Context)
PermissionsUtils.checkBluetooth(Context context)

returns true if bluetooth is ON

PermissionsUtils.isBleAvailable(context: Context)
PermissionsUtils.isBleAvailable(Context context)

returns true if BLE hardware/software is available on the device

PermissionsUtils.isAirplaneModeOn(context: Context)
PermissionsUtils.isAirplaneModeOn(Context context)

returns true if airplane/flight mode has been turned ON

PermissionsUtils.areNotificationsEnabled(context: Context)
PermissionsUtils.areNotificationsEnabled(Context context)

returns true if notifications are enabled, false otherwise