GPS with Android 12

Muchas gracias por tu información ,si es cierto que había oído sobre la mejora del calculo por conexión con otros GPS de referencia mejorando la precisión del GPS . Al parecer pueden conseguir precisiones de centímetros . Pero no pensé que esto era utilizado de alguna forma por mi Android, parecía que esto estaba reservado a GPSs de coste elevado.
Con relación al numero de satélites es cierto que cuatro satélites si están suficientemente distantes parece que puede dar una precisión suficientemente buena , pero mi experiencia es que cuando las cosas mejoraban era cuando tenia 8 o 9 satélites . Posiblemente será desde mi ubicación lo condiciona el resultado.
De todas formas aunque me he salido un poco del tema principal , ( espero que me disculpéis ) agradezco esta información que estudiare detenidamente, por que es un tema que me interesa . He trabajado no desde el punto de vista de un GPS Android sino con equipos equipos externos mandado datos a Android para representarlo en mapas de google y esto me abre un nuevo campo de conocimiento.

Saludos.

Here is my conclusion:
with android 12 the APP application does not really activate the gps ,

the gps icon is not in the status bar ,

the GPS coordinates received certainly come from the 4G / 5G network, which explains the poor precision,
in airplane mode I am not receiving GPS coordinates,
with the other GPS applications everything is ok,
before the android 12 update everything is ok,

thank you all
wait and see .......

1 Like

It's possible that Android 12 is returning the list of providers in a different order than earlier versions of Android. App Inventor obtains the list of available providers that the system claims can perform as needed based on the time/distance criteria and then tries starting them in order. The first one to become active is used. This may mean that in earlier versions of Android a list like "gps", "network" was returned and now "network", "gps" is returned instead. I don't have an Android 12 device right now so I cannot confirm this.

You could try adding the following blocks to your Screen1.Initialize and see if it resolves the issue.

Edit: Note that you can also get a list of the available providers using the property of the same name.

2 Likes

Check your device Settings. It appears you have accidently turned off your Location setting.
I experienced something similar. When Location is off, you will find the behavior you noticed.

To get my Android 8.1 tablet working again, I turned the Location setting back on. Then to get the gps to work again, I had to reboot/restart the Android. :cry:

There also seems to be a permissions problem on Android 12. How does one set Coarse and Fine permissions simultaneously as in the Google advice linked in post #10 ?

Regarding your ProviderLocked, shouldn't that come after setting ProviderName to gps ?

I don't have an Android 12 either.

1 Like

As far as the LocationSensor is concerned, we ever only ask for FINE location (see here), which up until now has also always implied COARSE location. Further, App Inventor apps still target Android 11, not Android 12, so those requirements do not yet apply (they will go into effect for apps starting next summer). As part of our update to comply with Google policies next summer we will make the necessary changes for Android 12 "improvements."

1 Like

Thanks. That probably means that developers will be limited to using the gps in Android 12 devices in Coarse mode (per Google's developer advice to submit both Coarse and Fine permissions simultaneously). That seems to mean the default Location permission of Coarse will have to be used with the existing LocationSensor control until a later release of App Inventor, sometime within the next 8 to 9 months and gps performance will be degraded (based on how I read Google's Android Location restrictions). (See post # 8 )

Simply, use of the gps seems to be broken (degraded) on Android 12 devices for the foreseeable future w.r.t. App Inventor developers.

@d_Taraoa There might be a work around for you.

On Android 12 and higher, users can navigate to system settings to set the preferred location accuracy for any app, regardless of that app's target SDK version. This is true even when your app is installed on a device running Android 11 or lower, and then the user upgrades the device to Android 12 or higher.

5 posts were split to a new topic: Android 12 Migration

Thank you for these details, I have the explanation for my problem

2 posts were merged into an existing topic: Android 12 Migration

@d_Taraoa: I would be interested in seeing how this app performs for you. I tested it on a Pixel 3 running Android 12 and was able to get an accuracy as low as 4.288 m depending on my distance from nearby buildings. The Pixel 3 in question did not have a SIM card nor was it connected to Wifi, so the results should have been coming from the GPS alone.

LocationSensorTest.aia (2.9 KB)

2 Likes

When I install LocationSensorTest I get an error message
if I finish the installation it's ok

I have modified LocationSensorTest with the FineLocation permission, I have no error during the installation and everything is OK
the Accuracy is 3 or 4 m
it is better that locationSensor is disabled in designer (I don't understand why) and to activate it in the initialization of the screen only
The GPS icon is in the status bar
and everything is correct.
I will modify my other applications and I will keep you informed
thank you so much

My Blocks and LocationSensorTest_2


LocationSensorTest_2.aia (3.0 KB)

1 Like

Yes, but not only on Android 12. I get the same error on Android 11 and 12 (Companion).
(But both permissions are declared in the Manifest of the Companion app.)

Hello
I did some tests on this rainy Sunday
the finelocation permission works if:
LocationSensor is disabled in designer
The permission request must not be in the initialization of the screen (otherwise I get a temporary permission, if I close the application the permission is lost)
I use a timer to ask for permission after initialization
we can also use a button
I tested with android 12 and android 8 it's ok

Some details:
TimeInterval is at least 5 seconds (battery protection?)
I have an empty list in the suppliers
the status changed function does not return any results


LocSensorInit.aia (3.5 KB)

2 Likes

Has you tested to asign the ProviderName = "gps" and nothing more (lets ProviderLocked = false)?. In this case you don't need to ask and manage the Fine-Permission. In my case it runs well with Android 12.

it's very simple and it works, I checked the permissions are granted
Thank you

My LG G8 thinkQ just updated its OS to Android 12 then GPS on my app showed weird output. Now I have to start fixing this problem while I'm not sure where to begin. I just share a screenshot how this problem serious. Now just let you know, GPS works well on my app before Android 12 update.

What is weird Bob? It is impossible to tell from the image you posted. Please explain.
you might post an aia or your Blocks. Impossible to provide advice without sharing code.

Do you have a screen image prior to upgrading to Android 12 to share?