how to get satellite name or number when we are getting location through GPS in Android?(在Android中通过GPS获取位置时如何获取卫星名称或编号?)
问题描述
我是 android 新手,我通过 gps 获取位置,我也在代码中获取卫星编号,但我想获取用于获取位置的特定卫星名称或编号.我有很多谷歌,但没有得到适当的解决方案.
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.
我的问题是:-<代码>1.是否可以获得特定的卫星名称或编号?如果是,请帮助我如何找到它?
提前致谢
推荐答案
locationManager.getGpsStatus(null).getSatellites()(调用者可以传入一个GpsStatus对象来设置最新的状态信息,或者传入null来创建一个新的GpsStatus对象.)
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.)
返回代表当前状态的 GpsSatellite 对象数组GPS 引擎.
Returns an array of GpsSatellite objects, which represent the current state of the GPS engine.
locationManager.getGpsStatus(null).getSatellite().getPrn()返回卫星的 PRN(伪随机数).
locationManager.getGpsStatus(null).getSatellites().getPrn() Returns the PRN (pseudo-random number) for the satellite.
getMaxSatellites()返回 getSatellites() 可以返回的卫星列表中的最大卫星数.
getMaxSatellites () Returns the maximum number of satellites that can be in the satellite list that can be returned by 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()+ "
";
Log.d("SATELLITE",lSatellites);
}
}
}
}
这篇关于在Android中通过GPS获取位置时如何获取卫星名称或编号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在Android中通过GPS获取位置时如何获取卫星名称或编号?


基础教程推荐
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01