title: getLastKnownLocation() returns null using GPS_PROVIDER
body: <p>I'm making a little test program to get the hang of Android GPS, and see how the battery is effected for a school project. I simply want my device to detect my location by printing out the latitude of the last known location detected. But the location always returns null in the onResume() callback.</p>
  
  <p>Any help is greatly appreciated. </p>
  
  <pre><code>TextView Updates;
  long start = -1;
  long battStart = -1;
  long stop = -1;
  PowerManager.WakeLock wl;
  LocationManager locationManager; 
  LocationListener locationListener;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      Updates = (TextView) findViewById(R.id.textView);
      Updates.append("\n onCreate()");
  
      batteryLevel();
      start = System.currentTimeMillis(); 
  
      locationManager = (LocationManager)getSystemService(LOCATION_SERVICE);
      locationListener = new LocationListener() {
          public void onLocationChanged(Location location) {
            // Called when a new location is found by the network location provider.
            Updates.append("\n Found a place! "+location.getLatitude()+","+location.getLongitude());
          }
          public void onStatusChanged(String provider, int status, Bundle extras) {}
          public void onProviderEnabled(String provider) {
              Updates.append("yes"+provider);
          }
          public void onProviderDisabled(String provider) {
              Updates.append("No"+provider);
          }
      }; 
  }
  
  protected void onStart() {
      super.onStart();
      Updates.append("\n onStart()");
  
      // Set up a wake lock 
      PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
      this.wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag2");
      this.wl.acquire();
  
      locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
  }
  
  
  protected void onResume() {
      super.onResume();
      batteryLevel();
      Location loc = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
      if (loc != null) {
          Updates.append(String.valueOf(loc.getLatitude()));
      } else {
          Updates.append("loc is null");
      }
  }
  </code></pre>