Humour me, and try this:
GeoLoc.aia (71.0 KB)
(uses html5 geolocation)
To uskiara san,
I think if this my application has no error, this application must report updated position regardless long stay same place,
Maybe Appinventor2 helps us user to satisfy our object.
If it has some limitation that should be clear to user.
Why shall I use some extension?
I believe this must be solved within AppInventor2 function,
If device has cause of this problem, there is no problem in AppInventor2.
Dear @shigeki_suzuki san,
MIT AI2 isn't only a programming language, but is a Community, therefore anyone who is capable to contribute in empowering it, he/she can do by creating extensions and making them available to the community.
I didn't said that your code is wrong, my hint was simply referred to help in finding where is the root cause of the issue: by using the NMEA extension, you could have verified whether it is the device that isn't updating the position (but I believe not, since gmaps works immediately), or there is a lag in the LocationSensor component.
I also have given you some other hints about the use of the Location Sensor itself, related to its timings, accuracy and threshold distance: those setting are working perfectly on my car and on my historical rally car.
I just wanted to share what is working for me, with the aim at helping you to solve (or to bypass) the issue.
Best wishes for your project.
Kind regards.
EDIT
I've just had a look to your .aia and the following is what I have some doubts about:
in the designer page you set the TextBox1.text to 600 and in the blocks page you initialize the clock1 timer interval to textBox1.text *1000.This leads to a clock1 period of 600000 milliseconds if you don't change textbox1.text before hitting button1. In addition, please be aware that the settings "timer always fires" causes the clock1 to fire even if the screen1 is not shown, therefore when screen2 or screen3 are shown instead, the firing of clock1 can cause problems (i.e. access to UI components not available at that moment).
Because it might work that way, and AI2 cannot know the extent to which device manufacturers interfere with their devices' power-saving options.
So give my APK a try and let me know if it works on your device. I’ve successfully tested it on Android 13 and 16.
You may also want to try this:
I don't think that will help. A foreground service shouldn't have any impact on the LocationSensor, as the sensor independently determines whether to continue providing data during prolonged periods of inactivity (lack of movement).
But my test app (extension) should work.
To everybody concerns this issue,
I want to know this problem, that is Staying at same location makes application developed AppInventor and using Locationsensor, to stop to report correct position, is not common to Appinventor users,
If it is common, I want to the expert to improve AppInventor structure,
If it is not common, I must give up limit of my application..
I must use only the block Locationsensor,locationchanged.
On my old android 10 phone your app seems working ok ( with clock interval set to 60s and location interval to 6s ):
Noticed that the ProviderName is always “gps”
To everyone,
Today I found another important observation.
Simply closing and reopening the app does not refresh the location. The app still starts with the old parking position.
However, after powering off the phone completely and turning it on again, the app immediately reports the correct current location.
This makes me think the stale location may be stored by Android's location service rather than by my app.
Did you remove the app from recent?
To everyone,
I tested both
For 30 minutes my car stays same place. After then I move but location does not change until full stop. At full stop I tried both restart test.
In both cases, the app still started with the old parking location.
Only after powering off the phone completely and restarting it did the app report the correct current location.,
I suppose my application using LocationSensor can not communicate with LocationSensor after location does not change due to staying long time.
Of course Google Map shows correct current location.
LocationChanged is location base then if location does not change, locaton sensor will sleep.
So Time Base function will be needed, I suggest
Ok, have you actually tried out my APK (post #13)?
It should work—at least it does on my test devices (Android 16 and 13).
to Anke-san,
I can not find call Locationsensor.requestcurrentlocation in AppInventor parrets.
How can you introduce?
Try this GitHub - seekhope886/LocationEx: LocationEx Extension for MIT App Inventor 2 · GitHub
have fun ![]()
May be you can do these steps:
TimeInterval = 20000 ms
DistanceInterval = 0
ProviderName=”gps”
ProviderLocked = True
Enabled = True
In the event “LocationChanged” ignore the first latitude and longitude received (I suspect these are a cache values not valids)
In my App after I receive geolocations and after I ignore the first values I refresh the sensor with: Enable =False and Enable=True
In my case it seems run well. Every (more or less) 20-30 ms I receive new geolocations and not the old gelolocation.
@ewpatton I think that this problem seems the intial cache geolocation sensor issue. With the system timestamp sensor location block we could manage this situation more easly.