TMSFMXWebGMapsReverseGeocoding android sensor

Hi guys , when i use the code below and I invoke   TMSFMXWebGMapsReverseGeocoding1.LaunchReverseGeocoding with andorind

  procedure TForm1.LocationSensor1LocationChanged(Sender: TObject;
    const OldLocation, NewLocation: TLocationCoord2D);
  var
    LDecSeparator: String;
  begin
    try
      LDecSeparator := FormatSettings.DecimalSeparator;
      FormatSettings.DecimalSeparator := '.';
      if FCurrentPosition.Distance(NewLocation) > Accuracy then
      begin
        FCurrentPosition := NewLocation;

        latmap := NewLocation.Latitude;
        Longmap := NewLocation.Longitude;

        if ((latmap >= -90) and (latmap <= 90)) and
          ((Longmap >= -180) and (Longmap <= 180)) then
        begin
          cp := '0';
          try

            TMSFMXWebGMapsReverseGeocoding1.Latitude := latmap;
            TMSFMXWebGMapsReverseGeocoding1.Longitude := Longmap;
            TMSFMXWebGMapsReverseGeocoding1.LaunchReverseGeocoding;   <------
            cp := (TMSFMXWebGMapsReverseGeocoding1.ResultAddress.PostalCode);

          except
            cp := '0';
          end;
        end
        else
          showmessage('GPS error, location not found');
      end;
    finally
      LocationSensor1.Active := False;
    end;
  end;

 I get the next error



  procedure TForm1.LocationSensor1LocationChanged(Sender: TObject;
    const OldLocation, NewLocation: TLocationCoord2D);
  var
    LDecSeparator: String;
  begin
    try
      LDecSeparator := FormatSettings.DecimalSeparator;
      FormatSettings.DecimalSeparator := '.';
      if FCurrentPosition.Distance(NewLocation) > Accuracy then
      begin
        FCurrentPosition := NewLocation;

        latmap := NewLocation.Latitude;
        Longmap := NewLocation.Longitude;

        if ((latmap >= -90) and (latmap <= 90)) and
          ((Longmap >= -180) and (Longmap <= 180)) then
        begin
          cp := '0';
          try

            TMSFMXWebGMapsReverseGeocoding1.Latitude := latmap;
            TMSFMXWebGMapsReverseGeocoding1.Longitude := Longmap;
            TMSFMXWebGMapsReverseGeocoding1.LaunchReverseGeocoding;
            cp := (TMSFMXWebGMapsReverseGeocoding1.ResultAddress.PostalCode);

          except
            cp := '0';
          end;
        end
        else
          showmessage('GPS error, location not found');
      end;
    finally
      LocationSensor1.Active := False;
    end;
  end;



can I help you?

Sorry this is the error

---------------------------
Debugger Exception Notification
---------------------------
Project UBSPA.apk raised exception class EJNIException with message 'android.os.NetworkOnMainThreadException'.
---------------------------
Break   Continue   Help   
---------------------------

Hi, 


You are launching the reverse geocoding from within a different thread, please use the following code to thread queue the code and avoid the exception.

procedure TForm1.LocationSensor1LocationChanged(Sender: TObject;
  const OldLocation, NewLocation: TLocationCoord2D);
begin
  TThread.Queue(nil,
  procedure
  var
    cp: String;
  begin
    TMSFMXWebGMapsReverseGeocoding1.Latitude := NewLocation.Latitude;
    TMSFMXWebGMapsReverseGeocoding1.Longitude := NewLocation.Longitude;
    TMSFMXWebGMapsReverseGeocoding1.LaunchReverseGeocoding;
    cp := TMSFMXWebGMapsReverseGeocoding1.ResultAddress.PostalCode;
  end
  );
end;

Thanks , it work