Thank you for your reply.

That is the thing. I am using high accuracy and at first I am getting an
accuracy of 3m. It is after a minute that it switches to 2373 meters.
On Mar 7, 2015 11:32 PM, "gjs" <[email protected]> wrote:

> Hi,
>
> What Location mode (in Android Settings) are you using?
>
> To achieve 20m I think you need to have 'High Accuracy' or 'Device Only'
> so that the GPS receiver will be used for your Geo fence.
>
>  2373 m accuracy indicates you are probably using 'Battery Saving'
> Location mode (cell tower & wifi only)
>
> Regards
>
> On Sunday, March 8, 2015 at 9:28:53 AM UTC+11, Tony Pitman wrote:
>>
>> I wrote an app that uses location services. It creates a geofence around
>> my house and lets my app know when I come home. I am doing this in a
>> service in the background so that my app doesn't have to be the active app
>> to function. I was using the LocationManager api.
>>
>> I have a Samsung Galaxy Note 2 with Android 4.1 on it.
>>
>> The app was working perfectly.
>>
>> I upgrade the phone to Android 4.3 because it just became available.
>>
>> Now all of a sudden my app started getting notifications that I was
>> outside of the geofence when I was still inside and not even really moving.
>>
>> I did some searching and saw a video presentation from the Google IO
>> conference in 2013. It talked about the new Google Play Services (at the
>> time new) and all the great stuff they were doing with location.
>>
>> I decided to switch to that because it seemed like a better way to go.
>> When I studied the api I found that even the stuff in that video was
>> deprecated and there was newer stuff. I got excited thinking it would solve
>> my problem of accuracy.
>>
>> I just finished implementing my app using the Google Play services
>> Geofencing. Guess what? I have the same problem.
>>
>> I put in some logging and basically here is what happens:
>>
>> I use the Fusion request for location updates to figure out where I am. I
>> first look for an accuracy of < 10 meters for at least 5 samples. This is
>> done because my radius is 80 meters, so I have to have a high accuracy when
>> starting out.
>>
>> Once I get that I turn OFF the location updates and set up the geofence.
>> I use the location of my house that was previously gathered from a mapping
>> piece of my app with a radius of 80 meters. I would like to be able to go
>> down to 20 meters if I can get it working, but 80 for now.
>>
>> When I first create the geofence I get 2 notifications right away. The
>> accuracy on those events is 3.8 meters.
>>
>> I then let the app sit for about a minute.
>>
>> At that point I then get 2 more transition events. Both of them say I am
>> outside of the geofence. The accuracy on these events is 2373 meters.
>>
>> I can only assume that after a minute the api has switched to a lower
>> accuracy system for some reason.
>>
>> I then walked at least 80 meters away from my house and I never got any
>> more transition events at all.
>>
>> The question is what do I do about it? My app is even still the active
>> app, so this is not a background issue. I assume it might even be worse if
>> I was in the background.
>>
>> I have requested the highest accuracy.
>>
>> I have heard people say that the answer to this problem is to leave a
>> location update request going. Doesn't the defeat the whole purpose of
>> letting the api take over for us? Shouldn't I be able to say I need high
>> accuracy geofencing and the api just takes care of it?
>>
>> Here are some snippets from my code:
>>
>>
>>  public synchronized void buildGoogleApiClient() {
>>
>>  _googleApiClient = new GoogleApiClient.Builder(_context)
>>
>>          .addConnectionCallbacks(this)
>>
>>          .addOnConnectionFailedListener(this)
>>
>>          .addApi(LocationServices.API)
>>
>>          .build();
>>
>>  }
>>
>>     Geofence geofence = new Geofence.Builder()
>>
>>                .setRequestId(door.Id)
>>
>>                .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER |
>> Geofence.GEOFENCE_TRANSITION_EXIT)
>>
>>                .setCircularRegion(door.Latitude, door.Longitude, door.
>> ActivationDistance)
>>
>>                .setExpirationDuration(Geofence.NEVER_EXPIRE)
>>
>>                .build();
>>
>>          GeofencingRequest geofenceRequest = new
>> GeofencingRequest.Builder()
>>
>>      .addGeofence(geofence)
>>
>>      .setInitialTrigger(door.IsInside ? GeofencingRequest.INITIAL_
>> TRIGGER_ENTER : GeofencingRequest.INITIAL_TRIGGER_EXIT)
>>
>>      .build();
>>
>>
>>      LocationServices.GeofencingApi.addGeofences(_googleApiClient,
>> geofenceRequest, pi);
>>
>>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Android Developers" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/android-developers/I9EvF9sdSr0/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to