Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 1 to 1 of 1, page 1 of 1
<< previous next >>
TMS FMX WebGMaps
Using the TLocationSensor with ReverseGeocoding on Android
Using the TLocationSensor with ReverseGeocoding on Android
When using the TLocationSensor and you wish to do a reverse geocoding call from the OnLocationChanged event on Android, you always have to use a TThread.Queue around your code to avoid network exceptions ( for example: "Project ABC.apk raised exception class EJNIException with message ''android.os.NetworkOnMainThreadException''").
Example:
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;