Product   |

Background geolocation is easy (and fully compliant) if you know how! Part 1: Android

Anybody can use Situm indoor/outdoor positioning to build wayfinding & tracking applications both for Android & iOS. Typically, wayfinding apps compute the geolocation when they are running in foreground (that is, when their UI is showing on the smartphone screen). Tracking apps, on the other hand, need to compute geolocation both in foreground and background (e.g. when the user has blocked the smartphone screen). In this post, we will teach you how to compute positioning in the background with Situm SDK for Android, in a manner that is robust and fully compliant with Google policies. In a subsequent post, we will teach you how to do it for iOS.

A bit of context: Background and Foreground Services

First, a bit of technical context. In Android, apps that perform long running operations in the background must do it using a special component called a Service. You have guessed it: computing the smartphone’s geolocation is one of those operations. There are two kinds of Services that matter to us:

  • Foreground services. Perform the operations in some way that is noticeable to the user. Typically, a Notification in the system’s tray will be displayed.
  • Background services. Perform the operations in some way that is not noticeable to the user. That is, the user does not know in any way that the operation is running.

Background Services may be killed at any time by Android when the app is running in the background. Why? Well… for a number of reasons: to increase the battery life, to make CPU&RAM space for new apps, etc. Foreground Services, on the other hand, are usually guaranteed to be able to run for long periods of time even if the user does not interact with the app.

More context: ACCESS_BACKGROUND_LOCATION permission and new Google policies

Be patient, we’re almost there. In addition to Background and Foreground Services, there’s another important concept at play: the ACCESS_BACKGROUND_LOCATION permission. This permission is very important because in September 2020 Google announced new guidelines under which, starting 29th March 2021, all apps published in Google Play must either:

  • Stop requesting it, or
  • Justify via the Google Play Console its need.

According to the Android docs,  this permission is not required if the app is running a Foreground Service that has declared a Foreground Service Type of location, even if the smartphone screen is blocked.

So… How do I run Situm apps on the background?

You have probably guessed it at this point… In order to run Situm based apps in the background, we recommend to:

  • Run Situm SDK as a Foreground Service and,
  • Do not ask for the ACCESS_BACKGROUND_LOCATION permission.

The good news is that we have done most of the hard work for you. Our SDK runs in a Foreground Service by default, and from version 2.63.2 onwards our SDK does not require the ACCESS_BACKGROUND_LOCATION permission.

This way, your apps will be able to compute indoor & outdoor geolocation, even in the background, in a fully compliant fashion. To learn how to configure you Situm-based app using this mechanism, please visit our docs.

I’m running an old Situm SDK version, what should I do?

In terms of background positioning, Situm SDK versions from 2.44.0 to 2.63.1 required the ACCESS_BACKGROUND_LOCATION permission, therefore these versions are no longer compliant with Google’s new policies.

We recommend you update the Android Situm SDK version to 2.63.2 or superior and publish your app to Google Play again. It’s as simple as that!

Subscribe to our newsletter

BASIC INFORMATION ON DATA PROTECTION

Data controller: SITUM TECHNOLOGIES, S.L.
Contact: Data controller: situm@situm.es
Responsible for protection: dpo@situm.es
Purpose and legal basis: To manage the sending of SITUM newsletters only with consent.
Legitimation: Express consent of the interested party.
Recipients: The data will not be passed on to third parties with the exception of legal obligations.
Retention period: As long as the interested party remains subscribed to the newsletter (a link to unsubscribe will be available in each newsletter sent by Situm).
Rights: The interested party may at any time revoke their consent, as well as exercise their rights of opposition, access, conservation, rectification, limitation, deletion of data and not be subject to a decision based only on automated data processing, by writing to SITUM at the addresses indicated.
Additional Information: You can consult additional and detailed information on Data Protection in our privacy policy.

Please, download your copy here

Thank you for downloading our whitepaper. Please do not hesitate to contact us if you would like to know more about how our solutions can help your business. Download whitepaper


Close window