App not getting location sensor updates on new phone

I've been building some apps that work together. They work as intended on old phone(Moto g7, Android 9).
Had to get a new phone( Moto g power, Android 10).
Apps run and appear fine but no location change event seems to fire.

Setup test project:
Map
Location sensor
Textbox...multiline.
Set Map to show user and the location sensor.
Location Sensor enabled.
Sensor location change event: join lat, long and put in textbox.

Runs but nothing happens after letting it go for few minutes.
5 apps good on old phone but not on new. Any ideas would be appreciated.

I think Android 10 is not supported yet. Try to use the beta link and see if that makes a difference.

http://ai2-test.appinventor.mit.edu/

Also, don't use this for final exporting as it is testing and may be unstable.
ai2-test

Thanks, I'll check it out.

I went beta and recreated test project. I did add status change event handler for sensor. It was the same issue with no activity from location sensor. Also the map user marker never appeared on map. Thanks again.

Hi there, I'm trying to get the Location Sensor to update, but it doesn't on the regular ai2 nor on the ai2-test version.

Here is my minimal example:
image

The counter passes to 1 on app launch, but after it doesn't update anymore.
I've set the TimeInterval to 1000 ms.

I'm using an Android 14 phone.

Here is the project file:
location_sensor_copy.aia (1.9 KB)

Thank you in advance for your help!

If you go outside and are not testing inside on a desk without moving the phone does your code work. Take a walk. My guess your app will work but perhaps there is an issue with Android 14; my Android 13 works fine. :thinking:

You might want to read * Using the Location Sensor if you have not already. Then try the two example test aia's and tell us what happens.

The LocationChanged block executes its' code when your hardware gps receive recognizes a location change. You phone, by default uses Google's fused Provider which is stubborn.
There are things that you can do to force the Provider to gps.

Thanks for the quick answer @SteveJG!

I forced the provider to "gps" like you advised, but it's still not working...
image

It's strange, because on launch, it get the correct latitude, longitude and altitude.

I'll experiment outside with it tomorrow when the sun comes back :smiling_face:

Have a great day!

It does not work like that...
For an example project of how to set the provider to gps correctly and lock the provider see here

Taifun

1 Like

It worked! @SteveJG was right, I just had to go out!

For those wondering, here is the logic:
image

And here is the project file:
display_location_on_map.aia (2.8 KB)

Thank you as well for your help @Taifun!
If I understand well, the Screen1.initialize will trigger the Clock1 that will then set the gps provider and lock it.
What I'm not sure about is: why not simply perform those actions directly inside the initialize block?

1 Like

because GPS could be disabled
Taifun

I think I understand!
Are you using the Clock component because it is triggered after the Screen and Location widget's initialization?

  • Screen initialize
  • Widgets (Location, Map, etc.)
  • Clock triggered

the clock is used to wait until gps is available in property AvailableProviders

Taifun

1 Like