Can't find location stuff

I used the demo code only as an example of how to architect the usage of IFusedLocationOwner. You could do the same with the form, eg:

TExperimentalLocationMainForm = class(TForm, IFusedLocationOwner)
private
  FFusedLocation: IFusedLocation;
  // Snip
public
  constructor Create(AOwner: TComponent); override;
  { IFusedLocationOwner methods }
  procedure LocationReceived(const ALocation: JLocation);
  procedure LocationUpdatesChange(const AIsActive: Boolean);
  // Snip
end;

// Snip

constructor TExperimentalLocationMainForm.Create(AOwner: TComponent);
begin
  inherited;
  FFusedLocation := TFusedLocation.Create(Self, True);
end;
Dave, that has allowed me to tidy up the code a bit I hope, but now it just
prangs out with android telling me that there is a bug in the programme!

//Snip

type
  TExperimentalLocationMainForm = class(TForm, IFusedLocationOwner)
    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);
    constructor Create(AOwner: TComponent);
  end;

var
   ExperimentalLocationMainForm: TExperimentalLocationMainForm;
   FFusedLocation: IFusedLocation;
   FusedLocationOptions : tFusedLocationOptions;

//Snip

procedure TExperimentalLocationMainForm.LocationReceived(const ALocation: JLocation);
begin
   Memo1.Lines.Add('Latitude ' + Format('Latitude: %f12.7,   Longitude: %f12.7, Accuracy : %f5.2',
      [aLocation.getLatitude, aLocation.getLongitude, aLocation.getAccuracy]));
end;

//Snip

procedure TExperimentalLocationMainForm.ButtonStartClick(Sender: TObject);
begin
   if FFusedLocation = nil then
      FFusedLocation := TFusedLocation.Create(Self, 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;

//Don't think the constructor ever gets called.

constructor TExperimentalLocationMainForm.Create(AOwner: TComponent);
begin
  inherited;
  FFusedLocation := TFusedLocation.Create(ExperimentalLocationMainForm, True);
end;


end.

Hi Chester

I was just looking at your message to Dave and see from your code that you think that the constructor is not getting called.

I don’t know your code at all but should there be an ‘override’ in the constructor’s declaration.

That is

type TExperimentalLocationMainForm = class(TForm, IFusedLocationOwner) 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); constructor Create(AOwner: TComponent); override; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end; Hope this has helped. Regards Graeme

Thanks, Graham. However, after about 90 hours of work and failing to get the FusedLocation stuff to run, I have given up on it and gone back to plain GPS. Unfortunately, as I finally found in a little footnote in the help pages, if you want to get accuracy from locationlistener stuff you have to use IOS. (Wondered why I wasn’t getting a useful value!) So, despite the fact that the government want accuracy information in the GPS recordings, they are just going to have to put up with the basic GPS stuff until some of this coimplexity gets resolved. Sigh!

Dave, thanks for all your efforts. I have resigned it to the “too hard” basket, and the department can live without “accuracy” on its data! I will look at it in the future.