getlastknownlocation sempre retorna null após eu reinstalar o arquivo apk via eclipse

Recentemente, criei um aplicativo simples para obter a localização do GPS e exibi-lo no telefone Android. No começo eu consegui obter o local depois de algumas tentativas, mas depois de reinstalar o arquivo apk, o getLastKnownLocation () sempre retorna um valor nulo.

Ambiente de desenvolvimento usado: - API 10 gingerbread 2.3.6 - provedor de GPS é usado

abaixo está o código que eu apliquei no meu projeto android:

        public class MyActivity extends MapActivity{
protected void onCreate(Bundle savedInstanceState) {


    mapView = (MapView)findViewById(R.id.myTripMap);
    mapController = mapView.getController();
    mapView.setSatellite(false);
    mapView.setStreetView(true);
    mapView.displayZoomControls(false);
    mapView.setBuiltInZoomControls(true);//
    mapView.setClickable(true);
    mapController.setZoom(14);      


    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    criteria.setAltitudeRequired(false);
    criteria.setBearingRequired(false);
    criteria.setCostAllowed(true);
    criteria.setPowerRequirement(Criteria.POWER_LOW);
    provider = locationManager.getBestProvider(criteria, true);
    location = locationManager.getLastKnownLocation(provider);

    updateMyCurrentLoc(location);

    locationManager.requestLocationUpdates(provider, 2, 1,locationListener);



}


          private final LocationListener locationListener = new LocationListener() {
        public void onLocationChanged(Location location) {
          updateMyCurrentLoc(location);
        }

        public void onProviderDisabled(String provider){
          updateMyCurrentLoc(null);
        }

        public void onProviderEnabled(String provider){ }
        public void onStatusChanged(String provider, int status, 
                                    Bundle extras){ }
      };


      private void updateMyCurrentLoc(Location location) {



            if (location != null) {

             // other codes to get the address and display
            Toast.makeText(getBaseContext(), "provider used : "+provider).show();   //testing purpose
            } 
            else {
              str = "No location found";
              Toast.makeText(getBaseContext(), str, Toast.LENGTH_SHORT).show();
            }

        }
    }

Alguém pode sugerir uma solução possível para resolver o valor nulo retornado por getLastKnownLocation ()? Qualquer ajuda será apreciada. Obrigado.

questionAnswers(5)

yourAnswerToTheQuestion