# 6. Permissions

To ensure accurate detections, the Sentiance SDK requires specific permissions to be granted by the user during the application's runtime. It's crucial to obtain these permissions as part of your application's onboarding flow, explaining to the user why each permission is necessary. Below are the permissions required for proper functioning of the Sentiance SDK on Android:

## **Location**

When running the SDK on Android 6 and above, it is necessary to request the user for the location permission.

For devices targeting API level 29 and above, you are also required to ask for the [background location access permission](https://developer.android.com/reference/android/Manifest.permission#ACCESS_BACKGROUND_LOCATION) (i.e., allow all the time).

{% hint style="warning" %}
On Android 10 and above, the background location access permission is crucial for the SDK to function correctly. This permission enables the use of Google Play Service Geofences, which the Sentiance SDK utilizes for detection stability and battery efficiency.
{% endhint %}

The SDK automatically adds the `ACCESS_FINE_LOCATION` and `ACCESS_COARSE_LOCATION` permissions to your app's manifest, however it **does not** add the `ACCESS_BACKGROUND_LOCATION` permission.Therefore, it's essential to explicitly include it in your app's manifest as shown below:

{% code title="AndroidManifest.xml" %}

```markup
<manifest...>
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION">
    ...
```

{% endcode %}

## Activity Recognition (Android 10+)

For devices targeting API level 29 and above, you must ask the user for the [activity recognition permission](https://developer.android.com/reference/android/Manifest.permission#ACTIVITY_RECOGNITION). This permission grants access to the user's physical activity data, such as biking, walking, etc.

{% hint style="warning" %}
While this permission is not mandatory, granting it can improve the quality of detections. For example, the Sentiance SDK uses activity data to enhance the detection of trip starts.
{% endhint %}

The SDK does not automatically add the `android.permission.ACTIVITY_RECOGNITION` permission to your app's manifest. You must explicitly add it in the manifest as follows:

{% code title="AndroidManifest.xml" %}

```markup
<manifest...>
    <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION">
    ...
```

{% endcode %}

## Foreground Service (auto-granted)

Apps targeting Android 9 and above must have the `FOREGROUND_SERVICE` permission specified in the application manifest file.

The Sentiance SDK automatically adds this permission to your app's manifest. However, you should make sure to compile your app against API level 34, in order to support the foreground service types that are required by the Sentiance SDK. At the moment, these types are: [health, location, and shortService](https://developer.android.com/about/versions/14/changes/fgs-types-required).

For more details, please see [the following](https://docs.sentiance.com/a-complete-integration/android-sdk/pages/-Lk5gWQ1_x9lMxg2GJp6#incompatible-foreground-service-types-sdk-v6.5.0+) troubleshooting guide.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sentiance.com/a-complete-integration/android-sdk/permissions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
