Does staying at same place make Location Sensor stop updating location?

I am developing using App Inventor LocationSensor for GPS logging.

While driving, LocationChanged works correctly.

If I stay at the same place for about 10–30 minutes, LocationChanged stops updating.

The Clock.Timer still runs, but Latitude and Longitude remain unchanged.

Even after closing and reopening the app, the first location is still the old one for a while.

Google Maps shows the correct current location at the same time.

Is this a limitation of App Inventor LocationSensor, Android LocationManager, or is there any workaround?

It would really help if you provided a screenshot your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select “Download Blocks as Image”. You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun

Staying in the same place should mean that the Location Sensor repeatedly returns the same values - it hasn't stopped.

How long is 'for a while'? For the duration of lag time (still remaining in the same place), you can expect the same value to be returned. Generally, what you are seeing would be regarded as good, compared with a setup that is too fidgety, rapidly returning different values all the time. However if there is too much lag when the App is opened, it could be down to how the data is gathered and how it is stored. Clearing the cache might help but you probably don't have access to it unfortunately.

Google Maps is using very powerful data to return the location - from GPS satellites, nearby Wi-Fi networks, and mobile cell towers - generally resulting in fairly accurate location values, fast. It still depends on exactly where you are though, and perhaps the level of demand on their servers too.

Thank you.

The problem is not while staying still.

After leaving the parking lot and driving for several minutes, the app still reports the old location.

Google Maps updates immediately, but LocationSensor continues to return the previous coordinates.

Is there any way to force LocationSensor to request a fresh GPS fix?

Well, the location sensor performance can't be compared to Google Maps, as I explained. The Location Sensor component relies on the sensor in your device (smartphone), which might be a really great sensor or it might be a so so sensor.

I would build-in app inputs for location DistanceInterval and TimeInterval and try tweaking those two until the performance is the best you can get.

EDIT: You might like to try the above together with a list of providers found - in the List, you may find a known reliable local provider but GPS is normally best. Mind you, it is very much down to the sensor. My car takes up to 30 seconds to 'find' GPS. My daughter's car (same make, different model) is instant.

After gps is available in property AvailableProviiders set ProviderName to gps and lock the provider

Do you keep the app up and running?

Taifun

Could you be relying on TinyDB for last location but failing to keep it up to date?

I have temporarily unlisted this topic because of posts with inaccurate, misleading info etc that sew confusion.

Yes. I’ll say more in a minute… toggling LocationSensor1.Enabled from true to false to true should do that.

Please post your Project aia. It is impossible to see what you are doing without it. :wink:

How are you using a Clock in your app? A guess is this what might cause the posting of your location from changing but I do not see you code so only can guess. The code to determine how a GPS device in your phone works was changed several years ago by Google to allow developers to use a fusion system for the available Providers. If that is not set, Google defers to fusion which allows the system to decide which provider is in use. Does your code lock the Provider to gps ?

– Steve

Dear @shigeki_suzuki, in addition to all what the other Power Users have already suggested you, you can try what I'm doing succesfully on my car:
I set the LocationSensor.timerinterval = 1000 milliseconds ; the LocationSensor.distanceInterval = 0; the LocationSensor.Accuracy = 5. With these values once the position is fixed, the GPS data are updated every 1 second, irrespective of the distance made, and the data is considered good if the accuracy is less than 5 meters.
Another way could be the use of a powerful extension made by @Juan_Antonio, called KIO4_NmeaMessage.aix that you can find on his web site (KIO4.com)
Best wishes.

To Steve san,
NavTrace_V3.aia (64.3 KB)

I revise this application from LocationChage to Clock function ,
But there is same result trouble staying same place for a while proveonts gps update.
For example I parked for 30 minutes then move from there gps continues to send parking location since then.

After restarting this application , initial position is the parking position.
Contrary google map identify correct present position,

Suzuki

miss spell
right prevents

Try this on your test device. On my Pixel 7 Pro, Android 16 it works fine.

Thank you for the aia. :wink: A quick look at your code shows that you are using the fused LocationSensor Provider because you decided to use the default Provider (which is fused).This will happen if you do not set the Provider to gps and Lock it.

When the Location sensor is first activated, it immediately pulls the most recent cached location computed by the device (because the Provider is fused).. This l provides an instant coordinate before a fresh hardware fix (which can take 30–60 seconds) is fully established by your gps receiver. The coordinate is the LAST KNOWN LOCATION; your parking position, :slight_smile: ).

I expect that this place, or the current location or the present position is in a location that is hilly or mountainous and the gps receiver is having difficulty getting a satellite fix. If the device cannot get a satellite fix; your LocationChanged event will never fire.until it gets a fix. This is consistent with your comment “Even after closing and reopening the app, the first location is still the old one for a while.” When the gps receiver eventually gets a fix, you would see a LocationChanged event.

So , Does staying at same place make Location Sensor stop updating location? Yes, if you are using a fused Provider and if your device is having a long time getting a satellite fix. :smiley:

– Steve

To Steve san
Thank you for checking my .aia.

I would like to add one more observation.

The GPS works correctly from my home garage to the parking lot. During the drive, the LocationSensor updates normally and continuously.

The problem only appears after I stay in the parking lot for about 30 minutes. When I start driving again, the app continues to report the parking location for a while.

Also, this area is part of the Kanto Plain in Japan. It is a flat area, not mountainous or hilly, so I do not think satellite reception is the cause.

And also Google Map shows correct present position.

I will also test with ProviderLocked = true and ProviderName = "gps" as you suggested.

Suzuki

Yes, same here on an Android 13 test device.

Same result for me.

Dear Shigeki san, why not trying the NMEA extension from KIO4 ?
In this way you will see the "continuous" update of GPS data, directly on the NMEA0183 line.
"Continuous" means with the same frequency (i.e. period in time) that you assign to your clock1 polling event.

Another alternative:

  • 1st and 2nd html files with a clock, always returns the location as opposed to having a listener waiting for a change in location.

  • Using the watch function (3rd html file) for when location changes

Because it uses a webview (visible component), may not run in a background task (e.g. iToo) but works OK with keepAwake routines.

To Anke san & Relative on this issue

I think your comments based on your experience reveals this problem is not my own individual problem but common problem for AppInventor users.
I want the specialist of AppInventor to improve this matter.
It means location sensor must correct right present position after reporting same location due to long stay same position.

Suzuki

Does my app work for you?