Location Sensor issue

I am using Location Sensor in my app. When testing the app using Connect -> AI Emulator, the location sensor is not retrieving latitude and logitude at the beginning and shows the latitude and longitude as Zero.

When i go to mobile settting and switch of the location services and switch on. the location sensor in App inventor starts fetching latitude and longitude.

I have checked this in 3 phones at home and issue remains same.

The location services are set to Hi Accuracy (GPS and networks) and access to MIT AI2 companion is provided.

if i check google map apps, it fetches my current location correctly.

But with all above validation, if i press my location button in AI Inventor app , it returns zero and once i off and on the location services in mobile, app inventor app works fine.

Attaching the screenshot of code and error simulation. I am new to App Inventor, requesting community help.

1 Like

Most emulators cannot use the LocationSensor in an emulator. Use the LocationSensor on a real device and you should be happy (see infornatuib about using LocationSensor in below link). You need a LocationSensor and the Map component .

You use a WebViewer to place your location; that can work,it requires loading a Web page and takes a while. Consider the following more common way to display a map using the Map component (along with the Locationsensor)

Users see a latitude/longitude location as 0,0 when their gps receiver is unable to achieve a satellite fix. You say ’ location sensor is not retrieving latitude and logitude at the beginning and shows the latitude and longitude as Zero.’;. It is like that because it takes somewhere between 30 and 60 seconds in most instances to display a LocationChanged event (which happens when the Android finally determines where it is located). You can avoid see a 0,0 by being patient and using an if lat not equal 0 and lon not equal statement in the LocationChanged event handler to post correct information only when you device determines your geocoordinates. Do you want to know why? If you have not already read Using the Location Sensor , please read it. The article explains how the LocationSensor works and provides two aia files to experiment with if you choose to do so.

Does this help?

Regards,
Steve

1 Like