Get current location : 0:0

Hello,

I have an Fmx Android app.
When the user click a button, I need to store the current location in the database.
I used this code at first:

TMSFNCLocation.GetLocation(
procedure(const ARequest: TTMSFNCLocationRequest; const ARequestResult: TTMSFNCCloudBaseRequestResult)
Begin
ShowMessage(ARequest.Coordinate.Latitude.ToString+':'+ARequest.Coordinate.Longitude.ToString);
End
) ;

This app works well if I compile it for Windows, however on Android it gives me back '0:0' as location.
I do have "Access fine location" and "Access course location" permissions, also Google Maps can show the current location without any problem.

What is wrong? Thank you!

Hi,

We are not aware of any issues with TTMSFNCLocation on Android.
Can you please make sure the Geolocation API is enabled in the Google Developer Console?

Hi,

-I set the Service to lsIPStack (so I didn't us Google) and connection to lcHTTPS.
-Is there other component I can use for retrieving the current location for example with TomTom service?

Thank you!

  • Are you using a free account on IPStack? Please note that HTTPS is required on Android but not incluced in the IPStack free tier, you'll need a paid account.

  • At this time only Google and IPStack are supported for retrieving the current location. However this is a good suggestion and we'll consider adding support for more services in the future.

Yes, I used a free account on IPStack. I will also check the TLocationSensor component, but seemingly I can use only the OnlocationChanged event here.