I got into Tools/Manage Features, removed SDK/NDK and Java, got out, deleted all their subdirecories, and put them back in. It now works! Well, no compile errors, anyway.
Now for the program again. I have no idea what an “iFusedLocationOwner”, so just defined one, as IFLO : iFusedLocationOwner;.
Now it prangs on TFusedLocation.Create(IFLO, True), saying that it cannot find tFusedLocationClientDelegate in DW.FusedLocation.Android.
Here’s the code:
unit ExperimentalLocationMainUnit;
interface
uses Androidapi.JNI.Location,
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Memo.Types,
FMX.ScrollBox, FMX.Memo, FMX.Controls.Presentation, FMX.StdCtrls,
DW.Androidapi.JNI.Os, DW.Androidapi.JNI.Location, DW.FusedLocation.Android;
type
TExperimentalLocationMainForm = class(TForm)
ButtonStart: TButton;
ButtonStop: TButton;
Memo1: TMemo;
procedure ButtonStartClick(Sender: TObject);
procedure ButtonStopClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure LocationReceived(const ALocation: JLocation);
procedure LocationUpdatesChange(const AIsActive: Boolean);
end;
var
ExperimentalLocationMainForm: TExperimentalLocationMainForm;
FFusedLocation: IFusedLocation;
FusedLocationOptions : tFusedLocationOptions;
tempint1, tempint2, tempint3, tempint4 : integer;
IFLO : iFusedLocationOwner;
implementation
{$R *.fmx}
uses
DW.Androidapi.JNI.App;
procedure TExperimentalLocationMainForm.LocationReceived(const ALocation: JLocation);
begin
Memo1.Lines.Add('Latitude ’ + Format(‘Latitude: %d12.7, Longitude: %d12.7, Accuracy : %d5.2’,
[ALocation.getLatitude, Alocation.getLongitude, Alocation.getAccuracy]));
end;
procedure TExperimentalLocationMainForm.LocationUpdatesChange(const AIsActive: Boolean);
begin
tempint1 := 1;
end;
procedure TExperimentalLocationMainForm.ButtonStartClick(Sender: TObject);
begin
if FFusedLocation = nil then FFusedLocation := TFusedLocation.Create(IFLO, True);
FusedLocationOptions.Interval := 1000;
FusedLocationOptions.Priority := TJLocationRequest.JavaClass.PRIORITY_HIGH_ACCURACY;
FFusedLocation.SetOptions(FusedLocationOptions);
FFusedLocation.Start;
end;
procedure TExperimentalLocationMainForm.ButtonStopClick(Sender: TObject);
begin
FFusedLocation.Stop;
end;
end.