我是android的新手,正在通过gps获取位置,在代码中也获取了卫星编号,但是我想获取用于获取位置的特定卫星名称或编号。我有很多谷歌,但没有得到适当的解决方案。
我的问题是:
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);
}
}
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句