Location Sensor Unable to retrieve location with cellular data

Thanks @tatiang

@aikansh.dua044gefzj
See this project on old platform
https://x.thunkable.com/projectPage/614e0a44b5d2730010889902

You’re welcome.

Both of your demos (DnD and StP) work beautifully on my iPhone 11 with no errors.

1 Like

Will test via apk and update

1 Like

The only error that I would expect is when starting the app and Location Services is not active on the phone. There could be an error the first time as it will timeout before the Location Services starts on the phone.

I tried it on the apk it is completely random as you can see in the video attached below however I just want to retrieve the coordinates once and use an api so just like you did you applied an loop maybe I was thinking that there could be a loop that calls location till there is an error and once it has got the location it can just exit the loop and do the api conmand
https://drive.google.com/file/d/1AyYzP27XRZEe3ncCBl5p7o43vWdzVoHe/view?usp=sharing

1 Like

Of course you can exit the loop any time. I am using a timer here. All what you need to do is to check the green error block. If no errors then read the coordinates and stop the timer.

[Edit]
image

One thing to note is the Maximum Age. It will wait for 1000 millisecond before it reports an error. When using cellular data you might need to consider giving a little more time and I am setting the timer to fire every second, you might want to make it wait a little longer.

Set the timer to 2 seconds and age to 2000 and changed the blocks
image
And now it works perfectly @muneer Thanks!

1 Like

You’re welcome

I’m finally getting around to testing this on my Android device and it gives me the “location provider is unavailable” error message 2/3 of the time it fires. The remaining 1/3 of the time it fires, it displays the lat/lon info.

1 Like

Just increase the Maximum Age in the Location Sensor to 2000 and adjust the timer to fire every 2 seconds. Some Android devices needs a bit more time to provide the results.

I’ll try increasing the timer interval. But Maximum Age refers to the oldest GPS data that the sensor will return without querying new location data. It doesn’t have anything to do with sensor timeouts.

I also tried using a location sensor in an app I’m building and I see a similar problem on Android: if I manually check the location, it works about 1/3 of the time. I don’t have a timer in that app. Maybe I need to increase the Timeout value. I have it set to 10000.

1 Like