Samsung Galaxy devices cannot use geolocation.getCurrentPosition

Ok, so I have been looking for an adequate answer to this problem for quite some time. I have a web application that uses navigator.geolocation.getCurrentPosition to get user position.

The native browser on Samsung Galaxy devices almost always has problems with the getCurrentPosition code. I tried all sorts of variations of this code with callbacks and timeouts, but this is always the same problem. Many people have documented this problem, and some indicate that rebooting the device will work (sometimes restarting works, but not always), and the warning that users restart their device seems more ridiculous).

Has anyone understood which getCurrentPosition method to use to work with the Samsung Galaxy Device? Here is what I work with ...

 <script> $(document).ready(function(){ if( navigator.geolocation ) { navigator.geolocation.getCurrentPosition( success, fail ); } else { alert("Sorry, your browser does not support geolocation services."); } function success(position) { window.location = "mobile_set_coordinates.php?user_lat=" + position.coords.latitude + "&user_lon=" + position.coords.longitude + "&accuracy=" + position.coords.accuracy; } function fail() { // Could not obtain location } }); </script> 

There is also a link to one of the discussions on the issue: https://groups.google.com/forum/#!topic/phonegap/ESrHAjFHgFU

+7
jquery android samsung-mobile galaxy
source share
5 answers

I had the same problem as a few weeks ago. I tried to research about 2 weeks on the Internet, to study all the solutions that I can find. In the end, I found out that:

  • If Google Maps has never been opened on your target phone, this feature does not work.
  • Reset your GPS status, then restart your phone. This can help.
  • If step 2 does not work, reset the GPS status, enable the automatic time zone setting in the date settings, then reboot the phone.

To my knowledge, there is nothing wrong with the code. In fact, my code is almost the same as yours. This happens not only on Galaxy devices, but also on some HTC. I ran into this problem on Galaxy S2, Galaxy Note 2, HTC Nexus One, HTC One X and HTC Incredible S. I think this should be a problem between Android devices and code competition somehow.

Greetings

+18
source share

I had something very similar to me. GPS will work fine on every other device, but it will fail on Galaxy devices.

What I found out is that it may take more than 10 seconds to get the GPS location on these devices. I also had to turn enabledHighAccuracy to false. Here is my code.

  if (navigator.geolocation) { navigator.geolocation.getCurrentPosition( function(position) { // success! }, function() { // failed to get a GPS location before timeout! }, { enableHighAccuracy: false, timeout: 10000, maximumAge: 10000 }); } else { // no support for geolocation } 

Hope this helps!

+2
source share

I have a Samsung Galaxy Trend Plus GT-S7580. The geolocation on my site did not work with this device. Previously, he worked with the Asus control panel, and all the settings were opened for access to the Internet and from the Internet. As soon as I allowed access not only to mobile data, but also to the Wi-Fi network, as well as Google access and the collection of data associated with this parameter, it started working. In this case, it was just that setting.

+1
source share

I had the same problem on my Galaxy GT-N8013 tablet, getCurrentPosition doesn't seem to work on Android, but works on ios. To fix the problem, I first increased the wait time. Secondly, open the Google Maps app. Third, restart the tablet. He works after that.

 $cordovaGeolocation.getCurrentPosition({timeout: 30000, enableHighAccuracy: false}) 
+1
source share

For me, it seems to be a Chrome issue - the browser does not allow unreliable origins like HTTP. Should be resolved by transferring data via HTTPS ( see Chromium ). Worked on my Galaxy S7 Edge when trying in a different browser.

+1
source share

All Articles