How to avoid repeat the same satellite information in list?

I create a simple application for shows GPS sensor satellite informations. Informations shows as text and list never stop to updated with same repeat informations. How i keep the unique sattelites infos?Not repeat the same infos.

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);
  }
}

Answers


I think your problem is that you're not clearing your strGpsStats between each call to the onGpsStatusChanged; although not sure because your question is not very clear. Try this:

public void onGpsStatusChanged() {
  strGpsStats = "";
  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);
  }
}

Need Your Help


About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.