[PAID] πŸ“ Location Service Extension

MySQL on your own web server, see for example App Inventor Tutorials and Examples: MySQL | Pura Vida Apps or Google Spreadsheet using the web component following this tutorial METRIC RAT AI2 - Google Sheets - Simple POST and GET Data

You might want to read again the documentation here App Inventor Extensions: Location Service | Pura Vida Apps

Before starting the service use an if statement to decide, if you want to use the background web feature or not, see also the example project

Taifun

Thanks @Taifun , I'll try it.

I use the UPDATE query, the data is not changed but added.
Please help.

image

The update query does not convert magically into an insert query somehow. .

Follow my previous suggestions

Taifun

Thanks @Taifun, I'll try again

4 posts were split to a new topic: How to display all the data in the first row taken from a MySQL database

I have 2 questions

  1. I attached taifun location extension blocks into project built in location sensor then this happened. coordinate and other numbers attached in list. what numbers are those and how can i remove those numbers except coordinates.

  2. Can options like ProviderLocked to true, ProviderName to "gps" in LocationSensor also possible in TaifunLocationService? location accuracy weirdly lower so I have to try any optional test to improve accuracy. Or any other suggest options to higher accuracy rate?

I couldn't attached my project file as it include paid extension in it.
thanks in advance.

See the documentation at App Inventor Extensions: Location Service | Pura Vida Apps

Optional location data to be stored in TinyDB

As the collected data can be extensive, the following properties can be used to decide, if a specific location information should be stored in TinyDB or not.

So if you like only the coordinates stored in TinyDB, then only set the property Coordinates to true and the other properties mentioned there to false

Unfortunately not... please see the documentation about the available features. Did you enable GPS and allow location access all the time? Did you also grant location background permission? Which Android version are you using for your tests?

Thank you for respecting my t&c.. In case there are still questions you also can provide a screenshot of your relevant blocks...

Taifun

1 Like

See Taifuns advice. The following might help with respect to question #1

You should be able to post ONLY the latitude and longitude by only requesting the latitude and longitude.

fused indicates you are using the new 'feature' provider on Android 11+ devices intended to improve coordinate accuracy (it often does not). The other numbers are probably altitude in meters and perhaps the Accuracy

Hola, tengo una app que enviar datos en segundo plano con esta extension, funciona muy bien en dispositivos con android 11 o menor, pero en dispositivos con android 12 o 13 al presionar el boton para iniciar los servicios me bota de la aplicacion, alguien ha tenido algun problema similar que me pueda ayudar, Gracias.

(Hello, I have an app that sends data in the background with this extension, it works very well on devices with android 11 or lower, but on devices with android 12 or 13 when pressing the button to start the services, the application kicks me out, someone has I had a similar problem that you can help me, Thank you)

Please try the example projects on your Android 12 or 13 device and let us know, if these work for you...

Also nake sure to grant location permission always, not only while using the app...

Taifun

Hola de nuevo, muchas, gracias, mi app ya funciona en dispositivos android 12 y 13, creo el detalle estaba en que tenia la extensiΓ³n con fecha del 15/Jul/2022 y ahora con la ultima actualizaciΓ³n del 27/Sep/2022 me funciona perfecto, solo actualize la extensiΓ³n sin modificar nada mas, muchas gracias por su apoyo y ayuda.

(Hello again, thank you very much, my app already works on Android 12 and 13 devices, I think the detail was that it had the extension dated 15/Jul/2022 and now with the last update of 27/Sep/2022 it works for me perfect, just update the extension without modifying anything else, thank you very much for your support and help.)

1 Like

Hi, could you provide me with the new update of the extension i am still with the older version.thanks

as usual you can download it from the download folder of the locationservice extension
Taifun
PS: this question better should have been a PM...

1 Like

Hi,
I have a simple application, it takes the Latitude, Longitude and Current Datetime from the Location Service and use it to call a PHP file by way of GET say, www.mywebsite.com/mylocation.php?latitude=abc&longitude=abc&datetime=abc. The PHP file then does its thing and insert the date passed through the URL into a MySQL database. The application does this per interval set by a Clock Sensor object block, when the Clock timer fires. All of his these functions naturally do not work when the screen/cellphone goes to sleep. Which is why I purchased this extension.

I just need the extension to do this in the background... no idea how though... can you help... @Taifun

Please follow the documentation

and set the BackgroundWeb property to true, the RequestMethod property to GET and the Url property to www.mywebsite.com/mylocation.php?latitude=LATITUDE&longitude=LONGITUDE&datetime=DATETIME
before starting the service

It also would be a good idea to check the example projects, for example the locationserviceSpreadsheet.aia

Taifun

No, the application sends a new Get request after a location changed event was triggered in the background, do NOT use a clock component, as this will not work in the background... see again the example projects about how to use the extension

Taifun

Is your extension able to give me Lat and Lng with the .Location Charged function with the application minimized?

No

From the documentation at App Inventor Extensions: Location Service | Pura Vida Apps

LocationChanged
Indicates that a new location has been detected.
Note: This event only will fire if the app is up and running.

And also from the documentation

Also a background web functionality is available which can be used to send the location data to a web service of your choice using a web request. This could be used for example to store the location data in a MySQL database or to send an email after a location change was detected while the app is not running.

The example projects show you how to use the background web functionality

  1. to send an email
  2. to send data to a MySQL database
  3. to send data to a Google spreadsheet

You can send data in the background to any web service of your choice. If it works with the web component, the it will work with the background web feature of the extension, too

For firebase, follow this approach

Taifun

Great extension. @Taifun is a magician! Actually, it is possible to get information from the TinyDB when app is in the background, no need to send data to the server. Below I will show my solution how to get the last position every 1 second in the background, show the notification once and stop background process after 10 seconds.

Firstly, we need to define namespase of TinyDB and TaifunLocationService tag, where coordinates will be saved. Pay your attention on the Namespace of TinyDB1. It must be "TaifunLocationService". After that we should start the Location Service.

Next - Create an background process. It may be created by any event, in this example - a Button, but in my app I'm using TaifunTools extension, which looks for app's activity and starts this Service when activity status become "stop".

Next - we are defining some variables for background process and periodic event, which will trigger the special procedure every 1 second.

Π‘Π½ΠΈΠΌΠΎΠΊ экрана ΠΎΡ‚ 2023-06-16 12-50-49

The following images will be parts of the "back_step_2" procedure, which is started periodically by the event we defined in the previous step. The number of blocks is large, and, so to prevent microscopic letters on images, I divide the images into parts, in which you will see the block from the previous part at the beginning and the block from the next part at the end. Well, let's continue.

You can use TinyDB with location data to store another data, which can be used in background. But, values of tags MUST be single - without any spaces, commas, "&" and "-" symbols, because they used for parsing. If you need to store data with "&" and "-" symbols, replace them to another in parsing blocks. Spaces and commas are using for parsing obligatory.
That's all.
Maybe my parsing procedure not ideal, but it works.
Here I'm attaching aia file with blocks above. This file without TaifunLocationService.aix.
This aia contains some free extensions:
NotificationsStyle extension
Itoo extension for background tasks
KIO4_Terminal extension

aia file with solution:
GetCoordsFromTinyDB.aia (114.6 KB)

BTW, @Taifun, how often extension add data to the TinyDB? Is it equal to
component_set_get

2 Likes