Re: Function getGeolocation is not working on Android

Showing 1-19 of 19 messages
Re: Function getGeolocation is not working on Android Erick the Redd 10/22/12 11:02 PM
What version of Android are you testing on? What kind of device?

I have noticed that Samsung devices are very spotty with their GPS units. I have also noticed that ICS has some issues with GPS.

-- Eric

On Saturday, October 20, 2012 9:18:57 AM UTC-7, Mauricio Nunes wrote:
Hello friend;
I'm trying to use the function getGeolocation on Android, but this function is not working. Below is my code, but I don't have any result. 

<!DOCTYPE html>
<html> 
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
    <title>Map</title>
     
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/jquery.mobile-1.2.0.min.js"></script>
    
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
    <script type="text/javascript" src="cordova-2.1.0.js"></script>
     
    <script type="text/javascript">
      document.addEventListener("deviceready", onDeviceReady, false);
      
      // Cordova is ready
      //
      function onDeviceReady() {
     alert("onDeviceReady");
     navigator.geolocation.getCurrentPosition(onSuccess, onError,{ enableHighAccuracy: true });
      }

      // onSuccess Geolocation
      //
      function onSuccess(position) {
          var element = document.getElementById('geolocation');
          element.innerHTML = 'Latitude: '           + position.coords.latitude              + '<br />' +
                              'Longitude: '          + position.coords.longitude             + '<br />' +
                              'Altitude: '           + position.coords.altitude              + '<br />' +
                              'Accuracy: '           + position.coords.accuracy              + '<br />' +
                              'Altitude Accuracy: '  + position.coords.altitudeAccuracy      + '<br />' +
                              'Heading: '            + position.coords.heading               + '<br />' +
                              'Speed: '              + position.coords.speed                 + '<br />' +
                              'Timestamp: '          + 
   position.timestamp                    + '<br />';
      }

      // onError Callback receives a PositionError object
      //
      function onError(error) {
          alert('code: '    + error.code    + '\n' +
                'message: ' + error.message + '\n');
      }

      
      
      
    </script>
  </head> 
  <body> 
 
    <div data-role="page" id="index">
      <div data-role="header" data-theme="b"><h1>Map Header</h1></div>
      <div data-role="content" style="padding:0;">
        <p id="geolocation">Loading...</p>
      </div>
      <div data-role="footer" data-theme="b"><h4>Map Footer</h4></div>
    </div>
  </body> 
</html>

Re: Function getGeolocation is not working on Android Gwendolyn 11/7/12 2:57 AM
I have the exact same problem. Both succes and error callbacks don't get triggered. Does anybody have a solution for this?

Op donderdag 25 oktober 2012 15:53:58 UTC+2 schreef Francois Masurel het volgende:
Same problem for me.

Geolocation in one of our app is working perfectly fine on a HTC Desire with Android but fails on a Galaxy S3 with Android 4.1.1 (Timeout error).

Any help will be greatly appreciated.

Francois
Bordeaux, France
Re: Function getGeolocation is not working on Android Gwendolyn 11/7/12 2:59 AM
Also on a Galaxy S3

Op woensdag 7 november 2012 11:57:36 UTC+1 schreef Gwendolyn het volgende:
Re: Function getGeolocation is not working on Android Gwendolyn 11/7/12 6:53 AM
I upgraded to the latest Android software (4.1.1) and it appears to be working now.

Op woensdag 7 november 2012 11:59:56 UTC+1 schreef Gwendolyn het volgende:
Re: Function getGeolocation is not working on Android Yauri Edogawa 3/17/13 9:17 AM
I'm using Galaxy S3 with Android 4.1.2. but it's not working
any solution??
Re: Function getGeolocation is not working on Android Terry Collinson 4/15/13 8:39 AM
Hi, I think you need to also set a timeout=xxxx with enableHighAccuracy. Getting GPS readings can take some time particularly if it is off or has just been turned on.

On Monday, 15 April 2013 10:56:53 UTC+2, Adrian Hara wrote:
I have the same problem on a Galaxy S3 with Android 4.1.2. Neither the success or error callbacks are getting called! Everything works fine on iOS or desktop web browsers.

I have found, however, that if I set "enableHighAccurracy" to "true", the success callback gets called after a long time (1-2 minutes).

Anyone know what's going on?
Re: Function getGeolocation is not working on Android Jeremy 5/2/13 7:58 AM
Hi,

I have the same issue on Samsung S2 running Android 4.1.2.  I get a 'Timeout expired' in my error callback.  The call to get the position is asynchronous so make sure you provide a callback.

The same code works on my HTC Evo running Android 4.0.3.

I am running PhoneGap 2.2.

Did you solve this?

Cheers
Re: Function getGeolocation is not working on Android Chris Lambrou 5/3/13 8:28 AM
For me it was uber important to set a timeout in the navigator call options.  Once I did that, the callbacks starting talking... Good luck.

-  navigator.geolocation.getCurrentPosition(gotLoco,noLoco,{frequency:5000,maximumAge: 0, timeout: 100, enableHighAccuracy:true}); 
Re: Function getGeolocation is not working on Android Thread7 9/17/13 9:48 PM
I had similar problems to the ones described in this thread.  The call to getCurrentPosition would not work or simply timeout on my Galaxy S3 device.  However, a Motorola Razr HD Maxx worked fine.  Once I changed the getCurrentPosition call to include MaximAge and "enableHighAccuracy: true" it worked.
Re: Function getGeolocation is not working on Android Phil Merrell 9/30/13 10:21 AM
Adding allowHighAccuracy: true, and a maximumAge parameter also worked for me with the Samsung S4.  Thanks!
Re: Function getGeolocation is not working on Android Spaceman Spiff 10/9/13 3:07 AM
I test on Samsung S2, impossible to make it work. I use Phonegap 2.9.0,  i added allowHighAccuracy: true, and a maximumAge parameter
Re: Function getGeolocation is not working on Android Spaceman Spiff 10/9/13 4:28 AM
I believe that this is related:



It worked when I moved nearby a window,  when I go back to my office it does not work.
I want to point out  that I don't work in a basement...
There must be something wrong with Galaxy devices.


Re: Function getGeolocation is not working on Android johan baert 5/7/14 12:57 AM
I had the same problem. I tried every setting of location services. I added allowHighAccuracy: true, and a maximumAge parameter, didn't work.

Then i rebooted my samsung tablet and it worked!!!

Never forget the basic rule. Did you reboot your device?

if only i had thought of it sooner it would have saved me 3 hours of searching for a solution.

cheers

Johan

Op woensdag 9 oktober 2013 13:28:54 UTC+2 schreef Spaceman Spiff:
Re: Function getGeolocation is not working on Android julija....@privatbank.ua 5/8/14 5:21 AM
I had same issue. I've restarted my device also. But it is not good decision. When user will use app he won't restart device each time it happened....

среда, 7 мая 2014 г., 10:57:11 UTC+3 пользователь johan baert написал:
Re: Function getGeolocation is not working on Android shamaleyte 10/31/14 1:16 PM
Hello Guys, 

First make sure that your code is bug free  ! 
If you are sure then you need to do one more thing ! 
Justchange the security settings of your Android device.
Go to Settings -> Security -> Check the "Unknown sources" checkbox
in order to allow your apk to be run without any problem.

Hope it works, 

Best, 

20 Ekim 2012 Cumartesi 19:18:57 UTC+3 tarihinde Mauricio Nunes yazdı:
Re: Function getGeolocation is not working on Android Oscar Morales 12/9/14 2:12 AM

Has anybody figured this out?

In my Galaxy SIII mini, after a few hours, the geolocation stops working and returns "timeout error" all the time. Then, I reboot the phone and starts working again.

You can't ask the user to reboot all the time. There's to be a solution!
Re: Function getGeolocation is not working on Android shamaleyte 12/9/14 5:12 AM
Hey Oscar,

getGeolocation is not working well for me too , that's why I run "watchGeolocation" and  listen to geolocation time till I get a geolocation info.
As soon as I get one , then I stop listening to the service and show the location on the map.

That could be a way around . But I am also curious about what is wrong with getGeolocation() .

Best,

9 Aralık 2014 Salı 12:12:35 UTC+2 tarihinde Oscar Morales yazdı:

Has anybody figured this out?

In my Galaxy SIII mini, after a few hours, the geolocation stops working and returns "timeout error" all the time. Then, I reboot the phone and starts working again.

You can't ask the user to reboot all the time. There's to be a solution!
Re: Function getGeolocation is not working on Android Mike Programmer 5/7/15 1:31 PM
I have the same issue with Samsung Galaxy SIII. Cordova geo functions are not working. It's my third day spend on that and this is impossible to force it to be working...
Re: Function getGeolocation is not working on Android jcesarmobile 5/7/15 2:07 PM
You can file an issue on the cordova jira page, but cordova android geolocation uses html5 geolocation now, so the problems are the webbviews, not cordova