android - Fused Location Provider unexpected behavior -
android - Fused Location Provider unexpected behavior -
this how register app receive location updates:
mlocationrequest = locationrequest.create(); mlocationrequest.setinterval(consts.one_minute * 10); mlocationrequest.setpriority(locationrequest.priority_balanced_power_accuracy); mlocationrequest.setfastestinterval(consts.one_minute); builder builder = new googleapiclient.builder(context); builder.addapi(activityrecognition.api); mgoogleapiclient = builder.addconnectioncallbacks(this) .addonconnectionfailedlistener(this) .build(); mgoogleapiclient.connect(); .... .... @override public void onconnected(bundle connectionhint) { locationservices.fusedlocationapi.requestlocationupdates(mgoogleapiclient, mlocationrequest, locationupdatespendinginent); }
my pending intent been invoked in background in exact requested intervals...
so far good.
the problem: when wifi disabled/ not connected network, or when there no 3g/4g network info enabled - fused location provider not providing new location updates!!
my location access settings turned on, , gps satellites , wi-fi & mobile network location checked.
the bigger problem: in case, receive location updates callbacks via pending intent, lastly location knew (even if hr ago, , i'm long long gone away miles place)
according documentation of priority_balanced_power_accuracy
:
used setpriority(int) request "block" level accuracy. block level accuracy considered 100 meter accuracy. using coarse accuracy such consumes less power.
i'm expecting fused location provider open gps when have no other choice, or @ to the lowest degree won't provide new location updates if don't have any.
another unpredictable , disturbing issue:
i changed priority_balanced_power_accuracy
priority_high_accuracy
in order see how behaves (for 24 hours). intervals stayed same (10 minutes interval between updates). accurate location indeed received in phones no network/sim card, - battery drained out fast! when looked on battery history, surprised see gps radio on total transmission mode time!!!! , saw in log loction received every minute, requested location each 10 minutes (i don't have other installed apps opens gps receive locations..)
i noticed behavior on several devices (such moto x 2013, htc 1 x, nexus 5) , latest google play services (version 6.1.11) , , android kitkat 4.4.4
my application depends lot on user current location, , periodically receives location updates in specified interval long user logged in, don't want utilize priority_high_accuracy
mode, prevent battery drain..
my questions:
is fused location provider suppose utilize gps @ if set receive updates priority_balanced_power_accuracy
, don't have wi-fi or cell towers info ?
if does, doing wrong?
why i'm getting misleading location updates not correct? (as explained in the "even bigger problem" section..
why gps radio opened time instead of been opened 10 minutes interval when used priority_high_accuracy
parameter? (i don't have other installed apps triggers location updates faster..)
for questions specified,
1. fused location provider suppose utilize gps @ if set receive updates priority_balanced_power_accuracy
, don't have wi-fi or cell towers info ? & 2. if does, doing wrong?
apparently no source specified anywhere within documentation. either priority
options, through code, "source" of obtained location
"fused". [location.getprovider()
returns :"fused"] have seen gps beingness used when locationrequest has priority_high_accuracy. not utilize gps under other conditions.
4. why gps radio opened time instead of been opened 10 minutes interval when used priority_high_accuracy parameter? (i don't have other installed apps triggers location updates faster..)
the fastest interval has been set 1 minute. understanding, setfastestinterval given precedence on setinterval when value fastest interval shorter in duration value of setinterval. in case, 1 min against 10. not having other installed apps triggers location updates, given illustration , not specified case explicitly.
this controls fastest rate @ application receive location updates, might faster setinterval(long) in situations (for example, if other applications triggering location updates).
so, happens priority_high_accuracy
, requests location
on fastest interval set - 1min, using gps(kind of exclusively).
3. why i'm getting misleading location updates not correct? (as explained in the "even bigger problem" section..
need check code pendingintent
mechanism also. though there few things take note of: can add together location.gettime()
ensure , verify time of obtained location. not beingness updated, if there no wifi-cell towers in range , priority_balanced_power_accuracy
used. block level accuracy of location on first place, beingness used when "lastknown" called wouldn't help.
the battery consumption because of combination of gps , 1 min updates. seek setting fastest interval 5 or 10 mins, if suitable implementation priority_balanced_power
may not help if need absolutely accurate location. add together check location obtained in onlocationchanged
, depending on that, switch priority in locationrequest. helps in, surely, obtaining location generally, unless within building no line-of-sight gps , wifi-network off.
android gps google-play-services android-location location-services
Comments
Post a Comment