unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
System.Sensors, System.Sensors.Components, System.IOUtils;
type
TForm1 =
class(TForm)
Button1: TButton;
LocationSensor1: TLocationSensor;
Label1: TLabel;
Label2: TLabel;
LongLabel: TLabel;
LatLabel: TLabel;
Label3: TLabel;
RefreshLabel: TLabel;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure LocationSensor1LocationChanged(Sender: TObject;
const OldLocation,
NewLocation: TLocationCoord2D);
procedure Timer1Timer(Sender: TObject);
private
{ Private-Deklarationen }
f: TEXTFILE;
fs: TFileStream;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
{$R *.LgXhdpiPh.fmx ANDROID}
procedure TForm1.Button1Click(Sender: TObject);
var
s:
string;
begin
if Button1.Tag=0
then
begin
Button1.Text:='
Started';
Button1.Tag:=1;
s:=System.IOUtils.TPath.Combine(System.IOUtils.tpath.getdocumentspath,'
test.txt');
ShowMessage(s);
AssignFile(f,s);
ReWrite(f);
Writeln(f,'
Lat;Lng');
Flush(f);
//fs:=TFileStream.Create(s,fmCreate);
//fs.WriteData(string('Test').ToCharArray);
//s:='Lat;Lng'#13#10;
//fs.Write(PChar(s)^, Length(s));
end
else
begin
Button1.Text:='
Stopped';
Button1.Tag:=0;
CloseFile(f);
end;
LocationSensor1.Active:=(Button1.Tag=1);
end;
procedure TForm1.LocationSensor1LocationChanged(Sender: TObject;
const OldLocation, NewLocation: TLocationCoord2D);
var
s,s1:
string;
begin
try
RefreshLabel.Text:=DateTimeToStr(now);
s:=Format('
%2.7f',[NewLocation.Latitude]);
s1:=s;
s1:=s1+'
;';
LatLabel.Text:=s;
//fs.Write(PChar(s)^, Length(s));
//s:=';';
//fs.Write(PChar(s)^, Length(s));
s:=Format('
%2.7f'#13#10,[NewLocation.Longitude]);
LongLabel.Text:=s;
s1:=s1+s+#13#10;
writeln(f,s1);
Flush(f);
//fs.Write(PChar(s)^, Length(s));
except
RefreshLabel.Text:='
(invalid Position received)';
end;
Timer1.Enabled:=true;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
RefreshLabel.Text:='
';
Timer1.Enabled:=false;
end;
end.