Welcome! Log In Create A New Profile

Advanced

[WM23] GPSFollowMovement Not Working on Android Device

[WM23] GPSFollowMovement Not Working on Android Device
September 17, 2019 03:37PM
Hi everyone,

It's been a while since I'm trying to use the GPSFollowMovement function on Android. Long story short, the procedure passed in does not get called. And, of course, I am calling the GPSInitParameter function like this :

GPSInitParameter(gpsAuto, gpsPrecisionHigh + gpsEnergyMedium)

There's the procedure that calls the GPSFollowMovement function :

PROCEDURE PRIVATE StartFollowingMovement()

GPSFollowMovement(UpdateCurrentPosition, 5000, 5)

Debug.TraceMessage("GPS starts following movement.")

_followingPosition = True

And, there's the procedure passed in the GPSFollowMovement function :

PROCEDURE UpdateCurrentPosition(thePosition)

CurrentPosition = thePosition

Debug.TraceMessage(StringBuild("Current position updated to %1, %2.", CurrentPosition..Latitude, CurrentPosition..Longitude))

ToastDisplay(StringBuild("Current position updated to %1, %2.", CurrentPosition..Latitude, CurrentPosition..Longitude), toastShort, vaBottom, haCenter)

The ToastDisplay is only there for debugging purposes. This works perfectly on iOS (the toast displays with the new position), but it doesn't on Android.

Any help would be very appreciated !

Thank you.

Anthony Blanchette-Potvin
Re: [WM23] GPSFollowMovement Not Working on Android Device
September 19, 2019 04:54PM
Anthony

Have you looked at this example from PC Soft,
i think here's what you need.

I personally did something similar in WM18, unfortunately unable to open the source code.


[play.google.com]

[infosonline.net]



Edited 1 time(s). Last edit at 09/19/2019 05:29PM by infos.
Re: [WM23] GPSFollowMovement Not Working on Android Device
September 23, 2019 02:20PM
Hello,

I did look at it, but for another problem and it didn't help me very much.

However, concerning my actual problem, I looked at the Android GPS example project from PC Soft which does exactly what I want. In fact, I am pretty much doing the exact same thing in my project. But, when I built the example project and ran it on my Android device, I got the same problem : the procedure passed in GPSFollowMovement doesn't get called.

I thought that it could be the device ? It's not the best Android device and not the most recent too. So, that could be a step forward if it works on another device.

That said, thank you and have a nice day.
Re: [WM23] GPSFollowMovement Not Working on Android Device
December 02, 2019 02:47PM
Hello,

Did you get GPSFollowMovement to work on Android in the end?

I have also tried the GPS example on Android, when the position is shown on app opening but does not get updated.

This is testing with Android 9. I want to be able to get a gps reading without a pause and hourglass.

Thanks for any advice.

Peter
Re: [WM23] GPSFollowMovement Not Working on Android Device
December 02, 2019 03:20PM
Hello,

As far as I remember, it was the device's GPS that wasn't "strong" enough. I tried with multiple Android devices and some worked, some didn't.

What exactly is your device ?

Anthony
Re: [WM23] GPSFollowMovement Not Working on Android Device
December 02, 2019 03:35PM
Hello,

I am testing on a Sony Xperia XZ1 Compact running Android 9.

I'd read somewhere that later versions of Android are more restrictive with following movement, maybe there is a setting somewhere I need to change.

The GPSGetPosition() function is working, it just takes a couple of seconds looking at the hourglass, which I want to avoid.

Cheers

Peter
Re: [WM23] GPSFollowMovement Not Working on Android Device
December 09, 2019 02:48PM
Hello,

I am not sure what is happening behind these functions, but I know that if you wan't to avoid the hourglass, you have to use the GPSFollowMovement function.

When you call GPSGetPosition, you directly ask the GPS to compute the current position, so that's why the hourglass appears. In other words, it's not instantaneous. The GPS needs to have a precise enough position, a fix, before it can send you the position.

On the other hand, when you use GPSFollowMovement, you tell the system/GPS : "Hey, notice me when you've been able to locate me.". So, each time the GPS is able to make a fix, which probably happen on another thread, the function you passed in GPSFollowMovement is automatically called. That's why you don't see the hourglass, because the position is pre-computed.

Anyway, I really don't know where the problem comes from. In my case, it was the device. But, honestly, I won't be surprised if it came from the IDE (WINDEV, WLanguage and all). I'm personally not that impressed by PC SOFT.

I hope this helped a bit !

Anthony
Re: [WM23] GPSFollowMovement Not Working on Android Device
December 09, 2019 02:51PM
Also, make sure you initialize the GPS using the GPSInitParameter function. Here's the link to the documentation :

[doc.windev.com]

Wish you luck !



Edited 1 time(s). Last edit at 12/09/2019 02:51PM by Anthony Blanchette-Potvin.
Re: [WM23] GPSFollowMovement Not Working on Android Device
December 10, 2019 12:54PM
Thanks Anthony

Yes, I tried to follow and grab the last position, but it wouldn't work for me sad smiley

Cheers

Peter
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: