Problem Setting a Global Variable to LocationSensor.Latitude

I've been cleaning up a code snippet that i've been sharing here:

I've run into an issue that I thought would be worth creating a new thread for.

While I was developing the code in the above link, I was using companion, because I couldn't seem to get the LocationSensor.latitude to return correct values. No worries, I simply substituted a number block for the approximate latitude while I was testing using Companion.

Thus:

blocks (81)

Instead of:

I've now changed over to some near-final testing and started using apk builds to test. However, the compiled app does not seem to be passing the LocationSensor1.Latitude values through to my formulas. I am certainly able to return a value from LocationSensor1.Latitude using the following test:

Label1 displays the correct value in the compiled app.

To be clear, if I run the compiled app using:

blocks (81)

It works properly. But if I change it to:

Permission are granted.

Here is the procedure that calls upon the Latitude_Test variable:

Any idea of what might be going on?

This is probably because the LocationSensor doesn't return values at startup; it'll only return the location every TimerInterval (ms). This worked for me:

...or, you could just set the variable's value inside the procedure (a much easier alternative).

Ah, of course. Thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.