2

Just watched the session about new location capabilities: https://developers.google.com/events/io/sessions/325337477 and think that feature of GEOFENCES will be a good fit for my app. I also downloaded the demo app which while quite informative is not giving me the functionality I am looking for. So could someone please explain me or point me to some example on how could I add a geofencing detection to the app that works while the app is off. If you have seen the IO session and noticed the app Zillo that is what I am talking about.

What I know by now is that I don't want to use a constantly running service in the background that detects TRANSITION broadcast but would like to register for them in the manifest file and than handle them inside a broadcast receiver class. Something like you would do when using GCM messaging. So the questions are:

What broadcast needs to be registered in the manifest? When should I register my fences so they are registered only once and stay registered when the app is closed? Are there any pointers on how to optimize battery life in a case like this? If someone already has experience what radius for a geofence would you suggest to detect entering a large building (3000-5000 sqm ground floor area for example)?

Igor Čordaš
  • 5,785
  • 4
  • 42
  • 54

1 Answers1

2

I implemented what you are talking about. (using a broadcast receiver instead of a IntentService). I started with the sample code, then made a few small changes, listed in my response here.

It seems to be working fine when the app is closed.

As far as optimizing battery life, this is all done by the OS. You just register the fences and Android handles the rest. I think they have optimized it well, I haven't seen significant drain after registering almost 100 fences. But I haven't done extensive testing.

As far as the radius size, I suggest building a sample app that has a map in it, and put a pin on the lat lng and play with the radius till it looks right. For a wild guess, I'd suggest something around 150 meter radius?

--update-- More detail on what I've found as far as accuracy. I built a testing app to see track myself and see the accuracy, and been driving around for the last few weeks and checking it frequently. I've only been testing with gps off since thats similar to what most users will encounter when they are out and about. :

  • Outdoors, not close to any wifi signals: Not very accurate, something like 100-200+ meters
  • Outdoors, close to wifi signals: Surprisingly accurate. Between 10-30 meters. If I'm sitting outside a restaurant, or at a strip mall where there are wifi signals, it knows very well where I am.
  • Indoors: even with wifi, many times it seemed less accurate than outdoors. More like 30-50 meters.
Community
  • 1
  • 1
b-ryce
  • 5,752
  • 7
  • 49
  • 79
  • Thank you for your response. I got a hang of the new API quickly and you are fully right that the default example has almost all of my requirements. About the radius I am currently making the admin part that is going to be used to set the fences but that part of the question was more towards getting some info from other dewelopers experiences on how precise the geo-fences are. – Igor Čordaš Oct 25 '13 at 13:34
  • added more of my findings. – b-ryce Oct 25 '13 at 16:53
  • Great info update. I really like that you tested without the GPS because as you said many users will have that off. About outdoor accurately being 10-30 meters I will say that is quite awesome since it will definitely make my app and other apps that rely on this quite useful, al-thou for my case even those 200meters are ok (I even added the minimum radius of 100m in the admin part).. – Igor Čordaš Nov 07 '13 at 17:04
  • About the indoor not being so accurate I think it has to do with the way that wifi and mobile signals travel and with reflections. As Waleed Kadous in the IO speech and many others said wifi strength is quite effected people and as you probably know from experience mobile signals worst enemies are steel and concrete. – Igor Čordaš Nov 07 '13 at 17:08