????3??GpsStatus??????
??????????????λ????????????ò??裬??????????GPS????????????????????????????????GPS??????????????????????????????????????????????????й??????2????????????????????????????????????????????????????????????????
//Edited by mythou
//http://www.cnblogs.com/mythou/
private final GpsStatus.Listener statusListener = new GpsStatus.Listener()
{
public void onGpsStatusChanged(int event)
{
// GPS???仯???????????????
GpsStatus status = locationManager.getGpsStatus(null);
//?????д???????????????????????
GetGPSStatus(event?? status);
}
};
????4?????????????????
//Edited by mythou
//http://www.cnblogs.com/mythou/
private void GetGPSStatus(int event?? GpsStatus status)
{
Log.d(TAG?? "enter the updateGpsStatus()");
if (status == null)
{
}
else if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS)
{
//?????????????????????????????
int maxSatellites = status.getMaxSatellites();
Iterator<GpsSatellite> it = status.getSatellites().iterator();
numSatelliteList.clear();
//??????????????
int count = 0;
while (it.hasNext() && count <= maxSatellites)
{
//????????????????????У???????????
GpsSatellite s = it.next();
numSatelliteList.add(s);
count++;
Log.d(TAG?? "updateGpsStatus----count="+count);
}
mSatelliteNum = numSatelliteList.size();
}
else if(event==GpsStatus.GPS_EVENT_STARTED)
{
//??λ???
}
else if(event==GpsStatus.GPS_EVENT_STOPPED)
{
//??λ????
}
}
?????????????????????????????????????????????status.getSatellites()???????????GpsSatellite????
???????浽??????????棬????????????檔????????GPS??????????????GPS???????????????????????
???????LocationListener????λ????????????λ???仯???????????λ?????????????????????
????5??LocationListener??????
//Edited by mythou
//http://www.cnblogs.com/mythou/
private final LocationListener locationListener = new LocationListener()
{
public void onLocationChanged(Location location)
{
//???????????????????????Provider???????????????????????
updateToNewLocation(location);
Log.d(TAG?? "LocationListener  onLocationChanged");
}
public void onProviderDisabled(String provider)
{
//Provider??disable????????????????GPS?????
Log.d(TAG?? "LocationListener  onProviderDisabled");
}
public void onProviderEnabled(String provider)
{
// Provider??enable????????????????GPS????
Log.d(TAG?? "LocationListener  onProviderEnabled");
}
public void onStatusChanged(String provider?? int status?? Bundle extras)
{
Log.d(TAG?? "LocationListener  onStatusChanged");
// Provider????????á?????????ú????????????????л???????????
if (status == LocationProvider.OUT_OF_SERVICE || status == LocationProvider.TEMPORARILY_UNAVAILABLE) ????????????{
}
}
};
????λ?ü????????????????GPSλ?÷????仯???????????????????????????????????????GPS??????????????????????????????location?????????GPS?????λ?????????????γ??????????ε??????