www.webdeveloper.com
Results 1 to 5 of 5

Thread: geolocation failing on all android devices

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Lansdale, PA
    Posts
    88

    geolocation failing on all android devices

    Hi,

    I've got a mobile site with this code in javascript / jquery:

    PHP Code:
    navigator.geolocation.getCurrentPosition(function(position) {
            
    lat=position.coords.latitude;
                    
    lng=position.coords.longitude;
                    
    sensor="";
                    
    codeLatLng(lat,lng,sensor);
             }, function() {
               
    handleNoGeolocation(browserSupportFlag);
        },{
    maximumAge:60000timeout:2000enableHighAccuracy:true}); 
    This seems to work fine for most browser types, IOS, etc, but Android devices are failing. They hit the timeout, and drop down to the error function. Even if the device accepts the request to send its location.

    I haven't found much on this on the web - any ideas? The code seems to be running, it's just the "getCurrentPosition" that is timing out.

    -Jim

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    200ms isn't a very long timeout, maybe it just needs a bit longer to sync with the satellites the first time...

    what is the error code given to you in, oh wait, you don't get an error code in your code, so there;s no way to tell why it failed.

    Code:
    function errorHandler(err) {
      if(err.code == 1) {
        alert("Error: Access is denied!");
      }else if( err.code == 2) {
        alert("Error: Position is unavailable!");
      }
      handleNoGeolocation(browserSupportFlag); 
    }
    also, there might simply be a preference that disable this privacy-risking functionality, check the device's config.
    Last edited by rnd me; 04-25-2013 at 12:33 PM.

  3. #3
    Join Date
    Jul 2003
    Location
    Lansdale, PA
    Posts
    88
    Thanks for the reply - from some testing it looks like it fails on Samsung S3, Galaxy S3, HTC sensation 4.03, and probably some others.

    However, it does seem to work on other Android devices, like HTC Evo 4g.

    I upped the timeouts a little bit, but it was failing even after reloads AND also also agreeing to "Share" the location of the phone.

    Still researching.

    -Jim

  4. #4
    Join Date
    Jul 2003
    Location
    Lansdale, PA
    Posts
    88
    Update - after more experimentation, turns out the phones in question aren't even sending their location to maps.google.com. So I'm pretty sure I'm not going to find a resolution to this. It's something with the phone.

    -Jim

  5. #5
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    Quote Originally Posted by jimr451 View Post
    Update - after more experimentation, turns out the phones in question aren't even sending their location to maps.google.com. So I'm pretty sure I'm not going to find a resolution to this. It's something with the phone.

    -Jim
    that's what i figured, this stuff is fairly fool-proof for how actually complex the whole idea is...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles