我想在 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;
}
}
谁能帮我?