android - Delphi XE5 TLocationServices on Samsung Galaxy 2 not using GPS -


i have simple app should return current gps location, code below, based on tutorial provided embarcadero.

when executed, gps icon of samsung not display , location returned 100m off true location.

i've experimented various valued 'accuracy' , tried setting 'accuracy' both before , after setting object active - no change in behaviour.

other apps i've obtained, including 'maps' comes galaxy, show gps icon when in use , return correct positioning.

with gps icon not display, i'm assuming app not using gps - how instruct so? (fine location permissioned)

procedure theaderfooterform.formcreate(sender: tobject);   begin     locationsensor1.active := true;     locationsensor1.optimize := true;     locationsensor1.accuracy := 100000;     locationsensor1.distance := 0;  end;  procedure theaderfooterform.locationsensor1locationchanged(sender: tobject;   const oldlocation, newlocation: tlocationcoord2d); var   urlstring: string;   urlloadfile: tstringlist; begin   lbllat.text := newlocation.latitude.tostring;   lbllong.text := newlocation.longitude.tostring;    urlloadfile := tstringlist.create;   urlloadfile.add('<iframe');   urlloadfile.add('  width="' + webbrowser1.width.tostring + '"');   urlloadfile.add('  height="' + webbrowser1.height.tostring + '"');   urlloadfile.add('  frameborder="0" style="border:0"' );   urlloadfile.add('src=' + format(     'https://maps.google.com/maps?q=%s,%s&output=embed',      [format('%2.6f', [newlocation.latitude]), format('%2.6f', [newlocation.longitude])]) + '>');   urlloadfile.add('</iframe>');   urlloadfile.savetofile( 'sdcard/android/data/com.embarcadero.gridlock/files/urlloadfile.html');   // show map using google maps   urlstring := 'file://sdcard/android/data/com.embarcadero.gridlock/files/urlloadfile.html';   webbrowser1.navigate(urlstring);   urlloadfile.free;  end; 

thanks in advance, chris

when request location, don't have real guarantees gps used.

when not enough satellites in direct view, phone fall other methods return position. can use nearby wifi hotspots find out are, or can use gsm towers determine location, of course won't accurate gps.

try place phone near window, or go outside, , retry. make sure have clear view sky, don't stand under tree or between high buildings.

also, if didn't use gps while, can take 15 minutes before phone has updated information position of satellites (it's broadcasted satellies, it's slow). if have data connection, phone can download information via internet, can speed cold start, , you'll position fix faster.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -