0
我創建了一個簡單的應用程序來顯示GPS傳感器衛星信息。 信息顯示爲文本和列表永不停止更新相同的重複信息。 我如何保持獨特的衛星信息?不重複相同的信息。如何避免重複列表中的相同衛星信息?
public void onGpsStatusChanged() {
GpsStatus gpsStatus = locationManager.getGpsStatus(null);
if(gpsStatus != null) {
Iterable<GpsSatellite>satellites = gpsStatus.getSatellites();
Iterator<GpsSatellite>sat = satellites.iterator();
int i=0;
while (sat.hasNext()) {
GpsSatellite satellite = sat.next();
strGpsStats+= (i++) + ": " + "Pseudo-random number for the satellite: "+satellite.getPrn() + "," + "Satellite was used by the GPS calculation: " + satellite.usedInFix() + "," + "Signal to noise ratio for the satellite: "+satellite.getSnr() + "," + "Azimuth of the satellite in degrees: "+satellite.getAzimuth() + "," +"Elevation of the satellite in degrees: "+satellite.getElevation()+ "\n\n";
}
Satinfos.setText(strGpsStats);
}
}
也許需要數組? if data(i ++)!= data(i) – user2342687 2013-05-02 10:50:44
sat.Current not exist! – user2342687 2013-05-02 10:52:00