title: Phonegap in Android onDeviceReady function
body: <p>I am using phonegap in android development. I wrote that PoC, however I can not figure out why it does not change the latitude of profile variable. Actually </p>
  
  <pre><code>alert(profile.latitude);
  </code></pre>
  
  <p>runs before the</p>
  
  <pre><code>geoCode.setLocation();
  </code></pre>
  
  <p>here is my code;</p>
  
  <pre><code>document.addEventListener("deviceready", onDeviceReady, false);
  
  var profile = {
      name: "",
      id: "red",
      latitude: "xx",
      longtitude: "",
      setCoordinates: function (latit, longt) {
          this.latitude = latit;
          this.longtitude = longt;
      }
  };
  
  var geoCode = {
      onSuccess: function (position) {
          profile.latitude = position.coords.latitude;
      },
  
      onError: function (error) {
      },
  
      setLocation : function () {
          navigator.geolocation.getCurrentPosition(this.onSuccess, this.onError);
      }
  };
  
  // Wait for PhoneGap to load
  //
  
  function onDeviceReady() {
  
      geoCode.setLocation();
      //alert("2");
      alert(profile.latitude);
  };
  </code></pre>
  
  <p>thanks in advance</p>