facebook

Geolocation doesn’t work on mobile phone

  1. MyEclipse IDE
  2.  > 
  3. Mobile Tooling
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #347112 Reply

    Lofi
    Participant

    The geolocation check works on the web simulator, but not on the phone when I build my app via the Genuitec cloud service:

    Both

    alert("navigator.geolocation: " + JSON.stringify( navigator.geolocation));

    and

    alert("window.navigator.geolocation: " +  JSON.stringify( window.navigator.geolocation));

    return

    {} 

    ie an empty string. So the check for the geolocation object succeeds, but I don’t get any data at all. I ask for all permissions on the phone for testing purposes, just to be on the safe side.

    #347138 Reply

    Hi Lofi,

    Could you share your device details: model and OS? Also your MyEclipse version.
    A sample project would be very helpful to replicate the problem faster.

    #347161 Reply

    Lofi
    Participant

    Hello Octavio,

    thank you for the reply. MyEclipse 2014 Pro and Samsung Galaxy. I finally figured it out, found the info on some website. This code works:

    var options = { timeout: 31000, enableHighAccuracy: true, maximumAge: 90000 };
    navigator.geolocation.getCurrentPosition(onSuccess, onError, options);                            
    

    What I was missing was the options. Without the options the getCurrentPosition method didn’t return anything on my Samsung Galaxy.

    To be honest, if MyEclipse includes cordova.js and rte.js (what’s that used for?) it would have been really very helpful if there were sample code which uses the features.

    #347309 Reply

    Hi Lofi,

    Thanks for sharing your solution. I am curious to know if you determined the 31 sec timeout by trial and error? For example we typically see a success location returned in around 10 seconds if not sooner.

    We also appreciate your feedback and as I said in the other thread, we will be providing more cordova/phonegap examples as we get closer to the next release.

    #347313 Reply

    Lofi
    Participant

    Hello Octavio,

    the 31 sec timeout is just random. Got the necessary info from here:

    http://community.phonegap.com/nitobi/topics/geolocation_works_with_one_android_device_but_not_another

    The important part: Only when I specify these options (with whatever timeout), then I see the GPS icon blink on the top left corner, i.e. the phone is searching for a GPS signal. Without the options there’s no searching and I’m left with an empty geolocation result.

    The time I get a signal depends on whether I’m indoors or not, the weather, etc. The usual stuff. Sometimes I have to wait for a minute.

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Geolocation doesn’t work on mobile phone

You must be logged in to post in the forum log in