java - Why is my method returning in the middle? -
the following method executing half-way:
public void onlocationchanged(location newlocation) { double lat = newlocation.getlatitude(); double lon = newlocation.getlongitude(); boolean firstgoodfix = (waitingforloc && newlocation.getaccuracy() < 30); // <= execution stops after line if (currentlocation == null || firstgoodfix) { latlng mylocation = new latlng(lat, lon); map.animatecamera(cameraupdatefactory.newlatlng(mylocation)); } currentlocation = newlocation; if (firstgoodfix) { sendmylocation(newlocation); waitingforloc = false; } else { sendmylocation(); } }
when step through code, executes until indicated line , jumps closing brace , rest of code never executes.
newlocation
valid, , waitingforloc
(true). newlocation.getaccuracy()
should returning around 1000
. currentlocation
null. firstgoodfix
not appear in list of variables @ end of method leads me believe line not completing.
what's going on here?
edit
following suggestions below, i've changed structure of method , discovered no matter did, whenever value of waitingforloc
read, method stop executing. thing make work removing variable entirely.
i tried setting waitingforloc
= true first line of method ensure had value, made no difference. being set in onresume()
.
so question becomes: why reading variable cause execution stop? there doesn't seem relevant output in logcat
.
you have method there. split parts make firstgoodfix boolean separate booleans, re-operate firstgoodfix see if method coming couldn't possible less (or bigger or equal) 30 (like nan or error, god knows :)
Comments
Post a Comment