Determining the location on Android
- With the locationTracking option enabled
The location is determined with accuracy to the city.
The app requests GPS access. Battery consumption may increase.
- With the locationTracking option disabled
- The location is determined by the IP address with accuracy to the country.
The app requests GPS access. Battery consumption does not increase.Note. If you have enabled IP address masking, AppMetrica determines location with the accuracy to the country by the unmasked part of the IP address.
How to enable location determination
By default, the AppMetrica SDK is initialized with the enabled locationTracking option.
To determine the location more precisely, add to the
AndroidManifest.xml file one of the following permissions:
- android.permission.ACCESS_COARSE_LOCATION — For approximate determination.
- android.permission.ACCESS_FINE_LOCATION — For accurate determination.
<manifest> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <application>...</application> </manifest>Copied to clipboard
How to disable location determination
falsevalue into the withLocationTracking(boolean enabled) method when creating an extended library configuration:
// Creating an extended library configuration. YandexMetricaConfig config = YandexMetricaConfig.newConfigBuilder(API_key) // Disabling the data sending about the device location. .withLocationTracking(false) .build(); // Initializing the AppMetrica SDK. YandexMetrica.activate(getApplicationContext(), config);Copied to clipboard
To disable locationTracking after initializing the library, use the YandexMetrica.setLocationTracking(boolean enabled) method:
YandexMetrica.setLocationTracking(false);Copied to clipboard