I am trying to get the satellite information from the android and wrote this following code which is not giving any results, could any one point out why is it so?
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.gps);
final LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
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++) + ": " + satellite.getPrn() + "," + satellite.usedInFix() + "," + satellite.getSnr() + "," + satellite.getAzimuth() + "," + satellite.getElevation()+ "\n\n";
}
}
TextView tv = (TextView)(findViewById(R.id.Gpsinfo));
tv.setText(strGpsStats);
}
thanks
Nohsib
According to the docs for
LocationManager.getGpsStatus(...)…Try implementing
GpsStatus.Listeneron your Activity and overridingonGpsStatusChanged(int). Example…