Android location services

Setting up geolocation regions and location-based messaging in Leanplum

In our Android SDK, we will automatically track the GPS/cell-based location if its available to your app.

Set up location-based messaging

To use geofence regions to trigger messages and push notifications in your app, you must add a few keys in your AndroidManifest.xml file as shown below:

  1. Add the permission <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> (Required for geofencing)
  2. Link the Google Play services library to your project and add the metadata in the application tag. <meta-data android:name="" android:value="@integer/google_play_services_version" /> (Required for geofencing)

Other Use Cases of Leanplum Location

Disable location collection

If you do not want to send GPS/Cell location to Leanplum, you can call disableLocationCollection before start.


Manually set user location

Our SDK allows you to manually set the user location by calling setDeviceLocation with two arguments (see below) after calling start. If you manually set the location, you will also need to call disableLocationCollection before setting the location.

setDeviceLocation(location, type);
locationandroid.location.LocationThe location object representing the user's current location.
typeLeanplumLocationAccuracyTypeThe type of geolocation. Either CELL (default) or GPS (more precise).


Due to a limitation with Android, you can only have 100 regions active for your app at any given time. Leanplum optimizes usage by not monitoring regions for messaging campaigns that don't target particular users.