Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not seeing Geofence Transitions in Google's tutorial on Geofencing

I am trying to test Geofence functionality using Google's example: Creating & Monitoring Geofences. I have uploaded the code here.

Problem is that I never get a notification of entry or exit. I have Wifi, 4G and GPS on. I have tried to test in the following ways:

  1. I even walk out of my house for about 50ft and walk back in - but no notifications. I can see that play services gets connected and even the "GeofenceUtils.ACTION_GEOFENCES_ADDED in MainActivity.java" gets triggered, so I think Geofences are getting added correctly.
  2. Enabled Mock Locations in the Settings and used this Fake GPS App and changed location - starting from the same coordinates as the Geofence1 and then setting to something totally outside (in another state) - but I still dont get an exit notification.

What am I doing wrong? ANyone had success in running this Google's example: Creating & Monitoring Geofences. I have uploaded the code here for easy browsing.

I am just trying to learn Geofencing - detecting entry & exit. I WILL MARK ANY ANSWER AS THE RIGHT ANSWER THAT I CAN USE TO GET GEOFENCING WORKING ON MY REAL DEVICE

I enter the coordinates and radius below.

like image 512
user1406716 Avatar asked Apr 07 '14 06:04

user1406716


People also ask

How do I use Google geofence?

You can set up Google Ads geofencing on the ads displayed on search results, display and YouTube. To more specifically target a location, manually enter the location. Google will display the estimated number of users within the geofenced location that meet other criteria that you have defined.

How do I create a geofence in Google Maps?

To plot a geofence on the map, all you require are, center coordinates of the circle (latitude, longitude) and radius of the circle. With a GoogleMap object reference, you can use the addCircle() function which expects CircleOptions() object as a parameter.

How accurate is Google geofencing?

App developers can use native Android and iOS location detection to power their location-based experiences and engagement. However, native geofencing technology can only deliver accuracy of around 100-200 meters.


1 Answers

I was also having issues with the example code. One of the main issues I had was around declaring the ReceiveTransitionsIntentService. You don't need to add a BroadcastReceiver or request location updates, but you need to change your AndroidManifest to set the exported value to true, like so:

<service
    android:name=".ReceiveTransitionsIntentService"
    android:exported="true" >
</service>

Make sure that the path to the service is also correct.

I've simplified the Google example significantly and you can find the code and explanation here. I've removed the UI component and persistent Geofence storage, so this example should be easier to follow. Hope this helps!

like image 156
mari Avatar answered Oct 04 '22 19:10

mari