I am new in android, I am getting location through gps, I am also getting satellite number in our code but I want to get specific satellite name or number which is used to get the location. I have google so much but not getting proper solution regarding this.
My Question is:-
1. It is possible to get a particular satellite name or number ? if yes please help me how to find it ?
Thanks in advance
locationManager.getGpsStatus(null).getSatellites() (The caller may either pass in a GpsStatus object to set with the latest status information, or pass null to create a new GpsStatus object.)
Returns an array of GpsSatellite objects, which represent the current state of the GPS engine.
locationManager.getGpsStatus(null).getSatellites().getPrn()
Returns the PRN (pseudo-random number) for the satellite.
getMaxSatellites ()
Returns the maximum number of satellites that can be in the satellite list that can be returned by getSatellites().
Code :
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);
}
}
}
}
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 event) {
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);
}
}
}
}