Google Map Get My Location, error when localisation is dissable

When I turn off localization I get an error when “Get My Location” function:
Attempt to invoke virtual method 'double android.location.location.getlatitude() on a null object reference

Can I somehow check is localization is enabled before i do Get My Location?

I try to add location_sensor to check available provaiders and if contain ‘gps’ then do Get My Location, but Google Maps component get location too slow, so app get error anyway.

Welcome ! Read This documentation :

Thanks for repply,
I build simple test project:

When localization in phone settings is dissable, app get error and close.

Use Google Maps blocks , Read POST above​:+1:

Look And try yourself:


Check this Share your gps position - #8 by sugarlesscreator


Thanks for your replies. I read these threads before asking.
I’m looking for a way to check the status of a location and get true or false in response.
The “on location changed” block is problematic because nothing will happen as long as the location does not change.
An additional problem is that I also wanted to use the “accuracy” of the measurement, and I can only read it from “get my location”.

The KIO4_GPS extension is good and very similar to my problem, maybe there is a way to extend its functionality to get a logical return.
Unfortunately, I haven’t learned to write extensions yet, maybe someday …

Strange , do It inside my home :

But you have localization enabled in smartphone settings. How you app work when user disabled localization in settings? Some kind of error, information for user, prompt?

This is just an aia project running on the companion to show what we can do with Kodular. I did not generate apk to test on the smartphone.

If You check If mylocation is enabled with This block ? :

If I set the Enable My Location option to true once, it will always be true, no matter what I set in the phone settings. This is more for the UI, but is needed to read the current position data. The behavior is the same in apk and in Companion.

Why i want to use Google Map component:
I did a couple of tests last days to check “what are the differences between Google Maps and Location Sensor?”
Location Sensor probably is based only on GPS, because it has problems with locating in buildings. There is a problem with the sensor resuming after the phone is put to sleep, or with manually turning the location off and on. It helps to reset the application or the sensor. It has more data like speed and attitude. Reading data from the sensor is possible at any time, if there is no fix, we get 0, 0, which is easy to interpret.
The Google Maps module shows the location very quickly, even if the GPS has no FIX, very good in the city. The position reading interval is much slower, but it resumes on its own after sleep. Less data and these problems with reading if the location is turned off.