# Location

# Enable location

Location is one of the risk parameters that can be sent to the server. In order to enable collection of location by the Encap SDK, you must follow these steps:

  1. In your application configuration, check that ENABLED_RISK_DATA is set to ALL, or that it contains Location.

  2. Ensure that location permissions are inserted into the app manifest:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

For Android 10 and higher, consider adding

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>

Note

ACCESS_BACKGROUND_LOCATION is not necessary for foreground location collection. Note that this permission might be denied by the end-user.

The Encap SDK does not request Android system permissions. This means that the application using the Encap SDK needs to implement that request. You can do this by following the instructions in the Android developer documentation (opens new window).

# Disable location

You can disable location by removing the location permissions from the app manifest file:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>

# Enable for your app, disable for Encap SCA

You may have a use case where you need to disable collecting location data in Encap the SDK, but keep location permissions for the rest of the app. To do this:

  • Keep location permissions in app manifest.
  • Remove Location from ENABLED_RISK_DATA in your application configuration.

# Enable Google Play Services location

By default, when location is enabled in Encap, the library will use the platform version of location.

If you want to enable the Google Play Services location, the app needs to add the dependency to the app. Once you have done this, the library will then pick it up and enable it for all supported Android versions.

dependencies {
    implementation "com.google.android.gms:play-services-location:21.0.0"
}
Last updated: 04/03/2024 15:17 UTC