Reputation: 143
I´m trying on first fix do something. I just need one location after is gps fixed. I don´t know how to do it. I tried onLocationChanged, but is never called I tried onGpsStatusChanged and also is never called.
Is there any option how do something on getting first location?
public class CenyActivity extends FragmentActivity implements LocationListener, OnMapClickListener, GpsStatus.Listener{
@Override
public void onGpsStatusChanged(int event) {
if (event == GpsStatus.GPS_EVENT_STARTED) {
Log.d("zmenaGPS" , "GPS event started ");
} else if (event == GpsStatus.GPS_EVENT_STOPPED) {
Log.d("zmenaGPS" , "GPS event stopped ");
GpsStatus gs = locationManager.getGpsStatus(null);
Log.d("zmenaGPSgps status" , String.valueOf(gs));
} else if (event == GpsStatus.GPS_EVENT_FIRST_FIX) {
Log.d("zmenaGPS" , "GPS fixace ");
} else if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) {
Log.d("zmenaGPS" , "GPS EVET NECO ");
}
}
public void onLocationChanged(Location location) {
Log.d("Location", "change");
}
GPS is fixing fine, location can get... but I want run some method after first fix(if GPS isn't fixed berore lounch activity)
Thanks for help
Upvotes: 2
Views: 2538
Reputation: 18151
You need to add addGpsStatusListener
LocationManager locMgr = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
locMgr.addGpsStatusListener(this);
Upvotes: 3