Android Location permission

How to request Android location permission

  1. Location on Android
  2. Request Location Permissions
  3. Start Location Tracking
  4. Refresh Location with high frequency

To protect user privacy, apps that use location services must request location permissions. Check the Android Documentation about building location-aware apps for more details.

Location on Android

Android Location management provide users with a strong control and transparency over location data usages. Recent changes introduced dedicated permissions for foreground and background location.

Each permission has a combination of the following characteristics:

The Woosmap Geofencing SDK requires both accuracy permissions which are automatically added in the manifest along with the INTERNET, ACCESS_NETWORK_STATE, and RECEIVE_BOOT_COMPLETED. For Geofencing events capabilities you’ll also need to ask for the ACCESS_BACKGROUND_LOCATION permission:

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

Request Location Permissions

Permission needs to be granted by the user at runtime. Before trying accessing the users’ location from the background, ensure the user consent for required permission. You can do this by checking the ACCESS_BACKGROUND_LOCATION permission. Here is a sample to request permission:

private void requestPermissions() {  
     boolean shouldProvideRationale =  
    // Provide an additional rationale to the user. This would happen if the user denied the  
    // request previously, but didn't check the "Don't ask again" checkbox.  
    if (shouldProvideRationale) {  
        // Displaying permission rationale to provide additional context.  
                new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION},  
    } else {  
        // Requesting permission
                new String[]{Manifest.permission.ACCESS_FINE_LOCATION,  Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION},  

Start Location Tracking

Once you have initialized the SDK and the user has authorized background permissions , you can start tracking the user’s location in the background.

To start tracking, call:

protected void onCreate(Bundle savedInstanceState) {
    woosmap.startTracking( Woosmap.ConfigurationProfile.liveTracking );

To stop tracking, call:


The SDK supports three tracking profiles presets built to best meet your use cases.

Refresh Location with high frequency

Some use cases are more demanding on position collection or Geofence detection. To complete standard mode the SDK provides a high frequency location mode. This mode allows to retrieve a maximum of location collection. It also gains a more accurate detection of Geofences crossings. This mode can be set using the following method:


When activated, the SDK records user’s location each second. For battery and performance optimisation the SDK stop POI detection, Distance calculations and Zone Classification when enabling High Frequency. This mode can be used in background or when the app has been killed. Nevertheless, if you want to maintain a high location collection frequency in background we recommend using a Foreground Service. Because the High Frequency Location mode generates high battery consumption, it should be used for proper use cases, when user is well aware of the tracking and be turned off as soon as high frequent positioning is not useful anymore.

Was this article helpful?
Have more questions? Submit a request