Location
Location is one of the risk parameters that can be sent to the server.
Enable location
To enable collection of location by the Encap SDK, you need to carry out the following steps:
- In your application configuration, ensure that
ENABLED_RISK_DATAis set toALL, or that it containsLocation. - In the app manifest, ensure that the following location permissions are inserted:
Example: Location permissions in 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, you should consider adding the following:
Example: Addition for Android 10 and higher
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>NoteThe permission
ACCESS_BACKGROUND_LOCATIONis not necessary for foreground location collection. Be aware that this permission can 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.
To learn how to request system permissions in your application, you can follow the instructions in the Android developer documentation.
Disable location
To disable location, you need to remove the following 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 location (excluding the Encap SDK)
You may have a use case where you need to disable collecting location data for the Encap SDK, but need to keep location permissions for the rest of the app.
To do this, you need to:
- Keep the location permissions in app manifest.
- Remove
LocationfromENABLED_RISK_DATAin your application configuration, and/or setlocationEnabledflag in theEncapConfigto false.
Enable Google Play Services location
By default, when location is enabled for the Encap SDK, the library uses the platform version of location.
If you want to enable the Google Play Services location, then add the dependency to your app. Once you have done this, the library then picks it up and enables it for all supported Android versions.
- Gradle (Kotlin)
- Gradle (Groovy)
dependencies {
implementation("com.google.android.gms:play-services-location:21.3.0")
}
dependencies {
implementation "com.google.android.gms:play-services-location:21.3.0"
}
Prevent SDK location update requests
By default, when location permission is granted, the Encap SDK requests location updates:
- Whenever an
EncapConfigis set. - During most SDK operations.
If you want to prevent the Encap SDK from requesting location updates, then you can use the locationEnabled flag in the EncapConfig. This allows you to avoid unnecessary battery consumption if your app does not use any features from the Encap SDK that rely on the device's location.
If you disable location updates while location, geofencing, or SSID/BSSID features are enabled, then it may result in unintended behaviour.