title: Can't get current device location
body: <p>I am trying to get current location of my android phone and display the longitude and latitude in a toast. Here is a function I wrote. While debugging the code I see that the control never goes inside onLocationChanged function.</p>
  
  <p>From the following android documentation it looks like, when I call "locationMgr.requestLocationUpdates", it should call the callback function onLocationChanged. But that does not seem to happen in my code. 
  <a href="http://developer.android.com/training/basics/location/currentlocation.html" rel="nofollow">http://developer.android.com/training/basics/location/currentlocation.html</a></p>
  
  <p>I checked my phone has GPS turned on. I can not figure out what is wrong in the following code. Please help. </p>
  
  <pre><code>  public void getCurrentLocation(){
              LocationManager locationMgr;
      locationMgr = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
  
      LocationListener listener = new LocationListener() {
          @Override
          public void onLocationChanged(Location location) {
             // A new location update is received.  Do something useful with it  
  
                      String latitude = "latitude: " + location.getLatitude();
                      String longitude = "longitude: " + location.getLongitude();
                      String toastString = "location is" + latitude + "," +longitude;
                      Toast.makeText( getApplicationContext(),toastString,Toast.LENGTH_SHORT).show();
  
              }
          @Override  
            public void onProviderDisabled(String provider) {  
             // No code here  
            }  
  
            @Override  
            public void onProviderEnabled(String provider) {  
             // No code here  
            }  
  
            @Override  
            public void onStatusChanged(String provider, int status,Bundle extras)   
            {  
             // No code here  
            }  
      };
  
      locationMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER,0, 0, listener);
  }
  </code></pre>
  
  <p>I also have following two lines in my Manifest file.</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt;
  </code></pre>
  
  <p>Thank you for your help. </p>
  
  <p>I am using Eclipse and my phone(OS: Thuderbolt) has API level 15, target 4.0.4.</p>