Search code examples
javaandroidgoogle-mapsandroid-geofence

How to define Rectangle of Geofence in android


Currently I define Geofence using following method.

Geofence geofence = new Geofence.Builder()
                    .setRequestId("GEOFENCE")
                    .setCircularRegion(latitude, longitude, radius)
                    .setExpirationDuration(Geofence.NEVER_EXPIRE)
                    .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT)
                    .build();

And Now I need to know how to define a room of area as a Geofence to Detect enter and leaving the room. Is this possible?


Solution

  • I dont think you can specify a rectangular geofence (radio waves are circular after all). You could geofence the door (very small fence, not sure if you could make it that small and be accurate) then detect people going through the door.