Phonegap 2.5.0 geolocation does not work with android 4.0.4

I am trying to use the geolocation API (version 2.5) with my Android 4.0.4 device, but I am not getting anything. I use the code from the telephone documentation. According to them, “if GPS and Wi-Fi are disabled, he should find you using triangulation of Cell Tower triangulation ”, but this code does not give anything to me. When I connected to Wi-Fi, it gives me the perfect place, but when there is no Internet, it will not work. I successfully work with all other call APIs, but only the geolocation API gives me problems. Please help me solve this problem.

And one more doubt, forgive me if this seems like a funny doubt .... I use a Wi-Fi connection in my mobile phone and never connect to other services (2G, 3G, etc.). Does Wi-Fi location search only detect Wi-Fi, or does it also include 2g and 3g connections?

Thnaks in Advance

    <!DOCTYPE html>
       <html>
      <head>
    <title>Device Properties Example</title>

    <script type="text/javascript" charset="utf-8" src="cordova-2.5.0.js"></script>
    <script type="text/javascript" charset="utf-8">

    // Wait for Cordova to load
    //
    document.addEventListener("deviceready", onDeviceReady, false);

    // Cordova is ready
    //
    function onDeviceReady() {
        navigator.geolocation.getCurrentPosition(onSuccess, onError);
    }

    // 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>
    <p id="geolocation">Finding geolocation...</p>
  </body>
</html>

Caught to know one thing .. It will not work with 2g and 3g .. only works with WIFI

+5
source share
2 answers

I had the same problem: at first I thought that this could have something to do with PhoneGap or Android (there might be a compatibility problem or something else). But later I found out that I do not have a file config.xmlin the root folder (along with index.html) for PhoneGap attributes (HTML, CSS, JS).

config.xml , .., .

config.xml: http://bit.ly/gap-config

25 API .

config.xml, URL- / , .

:)

0

, , .

<script type="text/javascript" charset="utf-8" src="cordova-2.5.0.js"></script>

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>

= D

0

All Articles