2014-05-20 152 views
5

我是Android新手,我通過gps獲取位置,我也在我們的代碼中獲取衛星號碼,但我想獲取用於獲取位置的特定衛星名稱或號碼。我有谷歌這麼多,但沒有得到適當的解決方案。當我們在Android中通過GPS獲取位置時,如何獲取衛星名稱或號碼?

我的問題是: - 1. It is possible to get a particular satellite name or number ? if yes please help me how to find it ?

在此先感謝

+0

我會試試看,能否請您貼上您迄今爲止嘗試過的代碼? –

回答

0
public class SatellitesInfoActivity extends Activity implements GpsStatus.Listener { 

    LocationManager locationManager = null; 

    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.mylayout); 
     locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 
     locationManager.addGpsStatusListener(this); 
    } 

    @Override 
    public void onGpsStatusChanged(int) { 
     GpsStatus gpsStatus = locationManager.getGpsStatus(null); 
     if(gpsStatus != null) { 
      Iterable<GpsSatellite>satellites = gpsStatus.getSatellites(); 
      Iterator<GpsSatellite>sat = satellites.iterator(); 
      String lSatellites = null; 
      int i = 0; 
      while (sat.hasNext()) { 
       GpsSatellite satellite = sat.next(); 
       lSatellites = "Satellite" + (i++) + ": " 
       + satellite.getPrn() + "," 
       + satellite.usedInFix() + "," 
       + satellite.getSnr() + "," 
       + satellite.getAzimuth() + "," 
       + satellite.getElevation()+ "\n\n"; 

       Log.d("SATELLITE",lSatellites); 
      } 
     } 
    } 
}