Skip to content

KI-labs/gps-permission-checks-livedata

Repository files navigation

Monitoring GPS and Location Permission checks using LiveData

Background:

In Android apps, users need to allow specific permissions so that app can use that particular resource. All location tracking apps need “GPS to be enabled” and want users to allow “Location Permission” so that app can start receiving location coordinates. For our usecase, it was critically needed to ensure both of these requirements are fulfilled. If not, user should be alerted and informed on UI level during or after Onboarding and also when Location Tracking is started/running in background.

This is a sample app to demonstrate the usecase.

Motivation to publish my solution:

There are already native android ways to implement both of these checks but we tried to do it using LiveData which is a newly introduced API from Android to handle asynchronous operations using Subscribe/Publish mechanism. We faced our fair share of challenges and there was limited help available as not many have tried for this usecase. Solutions which are challenging are the best candidate to be shared with public because it means many others out there will face the same problems and it could save their time. At the end of the day, it’s basically giving back to the community.

What is this project about:

  1. UI (app is active): Checking for both elements, displaying state and showing dialogs for user to react accordingly

    Medium Article: Read Here

  2. Background (app is not active): Check for both elements as part of Service whenever it is started by System and inform user via notification so that user can enable them for us. Otherwise, location tracking won’t succeed at all.

    Medium Article: Read Here

How sample app looks like or behaves


                                     



                                     

About

Sample project to demonstrate how GPS and Runtime Location Permission checks can be done on UI and Background Service using LiveData

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages