Giter VIP home page Giter VIP logo

background-location-sample-ktx's Introduction

Location Tracking Example

The question "how do we do location tracking even when the app is in the background?" comes up frequently. This example application covers how to set up your permissions and using appropriate services to continuously get location updates.

Requirements

  1. JAVA 11 - Go to Preferences > Build, Execution, Deployment > Build Tools > Gradle > Gradle JDK
  2. Android SDK Platform 31
  3. Emulator running Android 12

Description

This application uses the Fused Location Provider API to get the devices location. By providing a PendingIntent the API will broadcast an Intent every time a location update is ready, which can be received via a BroadcastReceiver. Each location update is then stored in a Room database so that we can update the update the UI accordingly.

The app will attempt to request the necessary permissions each time we start the application, or show an error message to the user. Firstly, we request location foreground permissions, then we request location background permissions (aka "Allow all the time").

Android 12 has a greater focus on highlighting how apps are accessing private data, in our case location updates. A new feature care Privacy Dashboard in the device settings will show when apps are accessing such data. The app provides a rationale screen which explains why we are collecting location updates, which can be launched from the Privacy Dashboard.

Lastly, we may know what data we are accessing, but we may not know what third-party libraries are accessing. Using the AppOpsManager we can audit data access and capture/log that information. This doesn't necessarily add anything useful for end users, but will provide further insights for developers.

Main screen

References

Third-party libraries

(Excluding Android/Google libraries)

background-location-sample-ktx's People

Contributors

joostfunkekupper avatar shshch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.