我是 android 的新手,我通过 gps 获取位置,我也在我们的代码中获取卫星编号,但我想获取用于获取位置的特定卫星名称或编号。我有很多谷歌,但没有得到适当的解决方案。
My Question is:-
1. It is possible to get a particular satellite name or number ? if yes please help me how to find it ?
提前致谢
最佳答案
locationManager.getGpsStatus(null).getSatellites() (调用者可以传入一个 GpsStatus 对象来设置最新的状态信息,或者传递 null 来创建一个新的 GpsStatus 对象。)
返回 GpsSatellite 的数组对象,代表 GPS 引擎的当前状态。
locationManager.getGpsStatus(null).getSatellites().getPrn() 返回卫星的 PRN(伪随机数)。
getMaxSatellites () 返回可在 getSatellites() 返回的卫星列表中的最大卫星数。
代码:
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);
}
}
}
}
关于android - 当我们在 Android 中通过 GPS 获取位置时,如何获取卫星名称或编号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23753069/