Re: navigator.geolocation.watchPosition runs only once on Android

2,044 views
Skip to first unread message

javac

unread,
Aug 28, 2012, 11:10:02 AM8/28/12
to phon...@googlegroups.com
I updated to 4.0.4 and still only calls watchPosition once, calling
the success function, then never calls it again.  Any ideas?



On Tuesday, August 21, 2012 1:45:59 PM UTC-7, javac wrote:
Using 2.0 and trying to write a program that tracks the device

watchPosition() runs fine on IOS device, "pinging" every second
and returning a valid position into the success(p) function

Samsung Galaxy Android 3.1, when watchPosition() is called, I
get a single success(p) with a valid position, then it never runs
again.   failure(e) function is never called, neither is success(p),
it is almost like it ran synchronously that one time.

Identical code - totally different behavior :(

    options = { frequency: 3000, enableHighAccuracy:true };
    watchLocationId = navigator.geolocation.watchPosition(success, geolocfail, options);

getCurrentPosition() runs fine on both.

Simon MacDonald

unread,
Aug 28, 2012, 11:46:37 AM8/28/12
to phon...@googlegroups.com
I've been testing the upcoming 2.1 release today and I cannot
reproduce that behaviour.

Simon Mac Donald
http://hi.im/simonmacdonald
> --
> -- You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com
>
> To compile in the cloud, check out build.phonegap.com
>
>

Cauli Tomaz

unread,
Oct 30, 2012, 9:33:08 AM10/30/12
to phon...@googlegroups.com, jon.bat...@gmail.com
I think a possible workaround is to use a setInterval(...) to wrap a geolocation.getCurrentPosition function.

Cauli Tomaz

unread,
Oct 30, 2012, 9:46:14 AM10/30/12
to phon...@googlegroups.com, jon.bat...@gmail.com
Have you tried the other available options, too?

{ maximumAge: 3000, timeout: 5000, enableHighAccuracy: true };

Chuck Kollars

unread,
May 20, 2013, 5:56:09 PM5/20/13
to phon...@googlegroups.com
> Samsung Galaxy Android 3.1, when watchPosition() is called, I
> get a single success(p) with a valid position, then it never runs
> again.  

watchPosition() only _has_ to report when there's new information available
(either a more accurate rendering of the same position, or you moved so the
position is now different). Some older implementations of geoposition
reported more often (some even on a regular basis). Reporting only when
there's a change provides better performance and battery life and can work
correctly (provided your code is structured to expect that behavior).

HOWEVER it can be difficult to test. As you probably don't move during
testing, and as your device may already have a GPS (most accurate) fix on
your position, watchPosition() can _appear_ to go dead after responding only
once.

I'm looking for some sort of test procedure whereby whenever I need to I can
_force_ watchPosition() to respond. Unfortunately I haven't found one yet:-(




Pedro Padilha

unread,
Dec 6, 2013, 4:42:42 AM12/6/13
to phon...@googlegroups.com, jon.bat...@gmail.com
Any news on this?

I'm using phonegap 3.2, with Android API 17, on Android 4.1 Devices.
wathPosition only works once!
The GPS symbol disappears right after it get the first position fix.


If I remove the phonegap geolocation plugin, and keep the same code, it will use the native OS browser capabilities and it works perfectly !
GPS Symbol always there, and receiving positioning.


Is there any fix?
I will need to build a cross platform app, and I'm afraid if I don't use the phonegap plugin it may not work on other / older devices.


Thanks



Terça-feira, 21 de Agosto de 2012 21:45:59 UTC+1, javac escreveu:
Using 2.0 and trying to write a program that tracks the device

watchPosition() runs fine on IOS device, "pinging" every second
and returning a valid position into the success(p) function

Samsung Galaxy Android 3.1, when watchPosition() is called, I
get a single success(p) with a valid position, then it never runs

Michael Ossou

unread,
Jan 29, 2014, 8:38:16 PM1/29/14
to phon...@googlegroups.com, jon.bat...@gmail.com
Did you ever resolve this? I'm having the same issue.

Phonegap 3.3 using Adobe Build to Samsung Galaxy S4

Roger Godefroy

unread,
Feb 24, 2014, 8:55:22 AM2/24/14
to phon...@googlegroups.com, jon.bat...@gmail.com
Did you resolve this? I'm running into the same problem at the moment...

Op vrijdag 6 december 2013 10:42:42 UTC+1 schreef Pedro Padilha:

Ritvick

unread,
Oct 19, 2014, 2:31:47 PM10/19/14
to phon...@googlegroups.com
Is this resolved ? Do we have nay issue on git hub ?
I know we have a workaround,
but plugin should work properly to get hassel free cross platform
solution.


Alessandro Stella

unread,
Nov 15, 2014, 10:20:21 AM11/15/14
to phon...@googlegroups.com, ritvick...@gmail.com
It could be an hardware problem with some Socs (MTK, for example).
Try this:
- GPS/Triangulation OFF
- start your APP
- start GPS/Triangulation
- APP doesn't work
- restart APP (with GPS/Triangulation ON)
- APP works

In this case (and only in this case) it seems that there is only one solution: workaround with getCurrentPosition() and setInterval :-(
Reply all
Reply to author
Forward
0 new messages