I have this:
In the OnCreate method:
if (lastKnownLocation == null) {
Log.i("Location", "lastKnownLocation es null");
dialog = ProgressDialog.show(this, "Buscando...", "");
}
dialog is declared above, its a ProgressDialog.
Then, in a Handler:
handler = new Handler() {
@Override
public void handleMessage(Message msg) {
Log.i("Location", "Mensaje recibido2");
if(dialog!=null){
dialog.dismiss();
}
LatLng gpsrc = new LatLng(msg.getData().getDouble("lat"),
msg.getData().getDouble("lon"));
continuar(gpsrc);
}
};
My onLocationChanged method:
public void onLocationChanged(Location location) {
double nuevalat=location.getLatitude();
double nuevalon=location.getLongitude();
origen=new LatLng(nuevalat, nuevalon);
Bundle bundle=new Bundle();
bundle.putDouble("lat", origen.latitude);
bundle.putDouble("lon", origen.longitude);
Message mescoords = new Message();
mescoords.setData(bundle);
try {
handler.sendMessage(mescoords);
} catch (Exception e) {
e.printStackTrace();
}
}
This way, when the onLocationChanged method is called, a message is sent, which dismiss the ProgressDialog. Try if with ProgressDialog the user can back, Im not sure.