Location Sensor - Doubts


#1

Hi, HAppyBuilders,

I did a search in this forum but I couldn’t find any posts about this questions I have.

Here is my scenario::

I’m trying to send the location from 5 to 5 minutes (300000 ms in Location properties) and I want to save the lat and lng in my remote database, so I can show the actual position in my Website, using Google Maps, For that I’m using blocks this way:

image

So, my doubts are:

1 - Where do I have to put this block in order to keep sending the location? Screen1, ou another one or what?

2 - Does the user has to be using my app in order the sensor send the location? Or the app can be at “second plan”?

3 - I left the properties this way:

image

So, do you think the DistanceInterval can be 0 (zero)?


#2

@Kleyber_Derick They work independently.
Let’s say you want to do something when 100 meter distance is traveled. For this, set DistanceInterval to 100
Adding another condition: You want to do something when 5 minutes are passed. You add in TimerInterval of 300000


#3

Thanks @Nickon for your answer. So, according to the prints I showed you, everything is correct? Can
I take them this way?


#4

@Kleyber_Derick I believe that’s how its operating; its a OR condition. You should test it though :slight_smile:


#5

Ok, I’m gonna test it right now. About my first question
(1 - Where do I have to put this block in order to keep sending the location? Screen1, ou another one or what?) It does not matter where I put the blocks?


#6

That’s a good question and I’ll have to check onto that.
I would say, put locationSensor only on the screen that users will stay-on.
For example, don’t put it on splash screen.


#7

Great!!! I’ll wait for your checking.


#8

Does the user has to be using my app in order the sensor send the location? Or the app can be at “second plan”?

See link below… unless the user has the app in the foreground, it’s liable to be closed at any point. There’s a “test server” run by App Inventor that includes background services functionality, but the apps generated are not production ready.

https://groups.google.com/forum/#!topic/mitappinventortest/_HRqtgsJbx4


#9

Thanks @Thomas_Leavitt for answering me. In fact what I mean with “second plan” is not running in background but just running with no actions by the user. The app is still on, but the user could be using another app. In my tests here, I could see that the Location Sensor gives the new location if the user has moved from a place to another even whether he is using the app or not, but without close the app.