我想在GPS状态启用时调用一种方法。我已经写了这个,但是没有用。
private LocationManager locManager;
private GpsStatus mStatus;
locManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locManager.addGpsStatusListener(this);
@Override
public void onGpsStatusChanged(int event)
{
mStatus = locManager.getGpsStatus(null);
switch (event) {
case GpsStatus.GPS_EVENT_STARTED:
myMethod1();
break;
case GpsStatus.GPS_EVENT_STOPPED:
myMethod2();
break;
case GpsStatus.GPS_EVENT_FIRST_FIX:
break;
case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
break;
}
}
谁能帮我?
最佳答案
@Override
public void onLocationChanged(Location location) {
}
@Override
public void onProviderDisabled(String provider) {
// GPS Enable
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}