title: No location fix on GPS - Android
body: <p>I copy pasted the following code from this <a href="http://www.firstdroid.com/2010/04/29/android-development-using-gps-to-get-current-location-2/" rel="nofollow">link</a> . No location info was shown when i used a active device instead of emulator. Even Gps is enabled</p>
  
  <pre><code>public class UseGps extends Activity
  
  {
  
      /** Called when the activity is first created. */
  
      @Override
      public void onCreate (Bundle savedInstanceState)
  
      {
  
          super.onCreate (savedInstanceState);
  
          setContentView (R.layout.main);
  
          /* Use the LocationManager class to obtain GPS locations */
  
          LocationManager mlocManager = (LocationManager) getSystemService (Context.LOCATION_SERVICE);
  
          LocationListener mlocListener = new MyLocationListener ();
  
          mlocManager.requestLocationUpdates (LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
  
      }
  
      /* Class My Location Listener */
  
      public class MyLocationListener implements LocationListener
  
      {
  
          @Override
          public void onLocationChanged (Location loc)
  
          {
  
              loc.getLatitude ();
  
              loc.getLongitude ();
  
              String Text = "My current location is: " + "Latitud = " + loc.getLatitude () + "Longitud = " + loc.getLongitude ();
  
              Toast.makeText (getApplicationContext (), Text, Toast.LENGTH_SHORT).show ();
  
          }
  
          @Override
          public void onProviderDisabled (String provider)
  
          {
  
              Toast.makeText (getApplicationContext (), "Gps Disabled", Toast.LENGTH_SHORT).show ();
  
          }
  
          @Override
          public void onProviderEnabled (String provider)
  
          {
  
              Toast.makeText (getApplicationContext (), "Gps Enabled", Toast.LENGTH_SHORT).show ();
  
          }
  
          @Override
          public void onStatusChanged (String provider, int status, Bundle extras)
  
          {
  
          }
  
      }/* End of Class MyLocationListener */
  
  }/* End of UseGps Activity */
  </code></pre>