#off-topic
@d_Taraoa do you have an Android 12 phone?(can you pls tell its name?)
my phone is a Pixel 4a (5G)
Have you read the tutorial Using the Location Sensor and loaded and tested the two aia Projects?
It would really help if you provided a screenshot of 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
Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.
the problem appeared with updating my pixel to android 12, before everything was working normally i did this little test app to try to find what went wrong.
it works on android 8 and 9 but loses its sensitivity with android 12.
and the gps icon does not appear in android 12
the application is in French
attached the .aia fileTEST_GPS.aia (3.9 KB)
What does that mean, loses its sensitivity?
A guess is Android 12 might require the user provide a permission for a coarse and fine location using either Blocks or the using Settings to allow the installed app to use Location settings. Your existing Blocks might not provide that. I do not have an Android 12 and I cannot confirm that advice.
You might have to modify your existing app to use DefaultFileScope to Legacy (another guess).
Maybe this might help
https://developer.android.com/about/versions/12/behavior-changes-12#security-privacy
I confirm that since the update to android 12 my applications developed with App Inventor have poor GPS accuracy
I tested with GPS Accuracy Logger a little modified
The best accuracy with android 12 is 20 m
Permission fineLocation is granted but not active ???
I tested android 8 and 11 its Ok
GPSAccuracyLogger_New.aia (4.6 KB)
How you request permissions might be the issue. Please show your Blocks showing how you request fine and coarse location,
Note
To handle this potential user behavior, don't request the ACCESS_FINE_LOCATION
permission by itself. Instead, request both the ACCESS_FINE_LOCATION
permission and the ACCESS_COARSE_LOCATION
permission in a single runtime request. If you try to request only ACCESS_FINE_LOCATION
, the system ignores the request on some releases of Android 12.
It appears you are getting COARSE_LOCATION only.
see https://developer.android.com/training/location/permissions#approximate-request
@ewpatton might be able to help regarding how to request simultaneous permissions.
Por la pequeña experiencia que tengo con GPS, no creo mucho en el dato de precisión que indica la aplicación . Como ves en la imagen yo lo he cargado en un teléfono
Android 5.1 y seguro que esa precisión no es correcta . No puede dar 2 mts de error . No sé de donde saca ese dato, pero por lo que yo conozco esto depende mas del numero de satélites que ve y la ubicación que tienen entre ellos y con eso calcula unos parámetros que se llaman HDOP y VDOP que son un factor que multiplica al error para calcular los errores teóricos horizontalmente y verticalmente . Cualquier GPS de los que conozco el error esta por encima de los 3 mts a los que tendrías que aplicar el factor correspondiente en cada momento . El GPS de mi teléfono está por encima de ese error seguro .Mi pregunta es : ¿estas en un interior o fuera en la calle? , ¿en el campo en zona sin casas grandes , mucho cemento ? todo eso influye en la precisión. ¿puedes saber cuantos satélites estas cogiendo el GPS? si no tienes al menos 8 o 9 no llegaras a tener estos factores cerca de 1 que sería lo ideal para tener la mejor precisión posible.
Espero que te sirva de ayuda.
Saludos.
That is an image from a 5.1 Android and your existing app with fine/coarse location settings requested?
Using the Location Sensor addresses some of your questions Miguel.
An Accuracy of 2 m is possible. What may be happening with your 5.1 Android is the phone is possibly using both the gps and WIFI simultaneously when you set Coarse and Fine on some devices lower than Android 12. The LocationChanged event does not trip (fire) because a location change is not reported. Your Android 8 and 11 displayed Accuracy values more typical. Did you collect that data indoors or out. Take the test 5.1 phone outside and see what it reports (no wifi and a clear sky so the gps has an opportunity to achieve a new satellite fix) and let us know. Is there a difference?
The Accuracy of any single satellite fix depends on lots of factors ( GPS.gov: GPS Accuracy ) and not necessarily the number of satellites. Accuracy also depends where the satellites are in relation to the phone (far away or close or overhead or near the horizon).
Sorry, this is not true Miquel. Improved gps precision depends on how many constellations and channels the gps receiver is able to receive. It is not Android version dependant. What happens depends on the Android gps hardware. The MIT LocationSensor control is only capable of interpreting the GPS satellite information as far as I am aware. There are extensions that can interpret the GPS, GLONASS, GALILEO, BEIDOU, QZSS AND IRNSS and provide more precise location information than the LocationSensor depending on the availability of required gps hardware in the device..
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 .......
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.
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.
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.
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."
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.
Thank you for these details, I have the explanation for my problem