Location Manager

Before starting tracking location using Asset SDK, you need to request location permissions using LocationPermissionsManager.requestLocationPermissions()

Required permissions

1
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
2
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
3
4
// API level >= 29
5
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

Check if all requested permissions are granted

  • Fine location or Coarse location permission is Checked

    1
    LocationPermissionsManager.areAllLocationPermissionGranted(this)

You can request Fine Location and Coarse location permissions using permissionsManager.requestLocationPermissions(this) and handle the permission result in the onRequestPermissionsResult callback.

  • Request Fine location and Coarse location permissions first

    1
    permissionsManager?.requestLocationPermissions(this)
  • Handle the permission result

    1
    override fun onRequestPermissionsResult(
    2
    requestCode: Int,
    3
    permissions: Array<String>,
    4
    grantResults: IntArray
    5
    ) {
    6
    super.onRequestPermissionsResult(requestCode, permissions, grantResults)
    7
    permissionsManager?.onRequestPermissionsResult(requestCode, permissions, grantResults)
    8
    }

© 2024 NextBillion.ai all rights reserved.