Skip to content

Location tracking for Android and FireOS

Add at least one of the following permissions to your AndroidManifest.xml file to declare your app’s intent to collect location data:

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

ACCESS_FINE_LOCATION includes GPS data in reporting user location while ACCESS_COARSE_LOCATION includes data from the most battery-efficient non-GPS provider available (e.g., the network). Coarse location will likely be sufficient for most location data use-cases; however, under the runtime permissions model, receiving location permission from the user implicitly authorizes the collection of fine location data. Take a look at Location Strategies from Android Developers to read more about the differences between these location permissions and how you should utilize them.

Disabling automatic location tracking

To disable automatic location tracking, set com_braze_enable_location_collection to false in braze.xml:

1
<bool name="com_braze_enable_location_collection">false</bool>

Then you can manually log single location data points via the setLastKnownLocation() method on BrazeUser like this:

1
Braze.getInstance(context).getCurrentUser().setLastKnownLocation(LATITUDE_DOUBLE_VALUE, LONGITUDE_DOUBLE_VALUE, ALTITUDE_DOUBLE_VALUE, ACCURACY_DOUBLE_VALUE);
1
Braze.getInstance(context).currentUser?.setLastKnownLocation(LATITUDE_DOUBLE_VALUE, LONGITUDE_DOUBLE_VALUE, ALTITUDE_DOUBLE_VALUE, ACCURACY_DOUBLE_VALUE)
WAS THIS PAGE HELPFUL?
New Stuff!