我创建了一个显示 gps 传感器卫星信息的应用程序。但是迭代器循环不对,信息显示为文本永远不会停止更新。我想要每颗卫星的唯一信息,而不是相同的信息。如何修复它?
if (statoGps != null) {
Iterable<GpsSatellite> listSat = statoGps.getSatellites();
Iterator<GpsSatellite> sat = listSat.iterator();
int visibleSats = 0;
while (sat.hasNext()) {
GpsSatellite satellite = sat.next();
gpsStats += "SATELLITE " + (visibleSats++) +
"PRN: " + satellite.getPrn() +
"SNR: " + satellite.getSnr() +
"azimuth: " + satellite.getAzimuth() +
"el: " + satellite.getElevation() +
"fix: " + satellite.usedInFix() + "\n";
}
elencoSat.setText(gpsStats);
}