1

I have an android app where I implemented geofences using the following docs: https://developer.android.com/training/location/geofencing.html

However, I am having this issue where I get a geofence notification each time I launch my "Map" activity from my navigation bar. I want to make it so that the geofences register once when the app is started, and not each time I switch between the tabs. This is what my navigation bar looks like:

navigation bar

The issue I am having now is that each time I switch between tabs, and go back to "Map" I get the geofence notification again. I assume this is because I re-fetch all the coordinates from my firebase DB and register all geofences again. I am hoping there is a way to save the state of the geofences so when I switch between tabs I don't get a notification each time. All help is appreciated!

Alvin Lau
  • 101
  • 1
  • 11
  • can you check https://developer.android.com/training/location/geofencing.html#HandleGeofenceTransitions url. – Prags Jan 03 '18 at 10:25

1 Answers1

0

Answering this in case someone stumbles across it - the solution I used was to create my geofences when the app starts, which allowed them to be created and called only once.

This answer on this post was extremely helpful: How can I execute something just once per application start?

Alvin Lau
  • 101
  • 1
  • 11