android - 当我们在 Android 中通过 GPS 获取位置时,如何获取卫星名称或编号?

标签 android gps geolocation location

我是 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/

相关文章:

javascript - 使用 Android 版 wikiitude SDK 获取用户位置

android - 通过 Android 应用程序在 Twitter 上分享视频

android - 下载android 2.3.4 API

安卓 :How to get Current Location in Longitude and latitude?

objective-c - 如何根据核心位置坐标获取本地时区?

ios - iOS 上这些基于地理的通知方法有什么区别?

javascript - meteor 自动将地理位置保存到用户文档中

Android SQlite,如何将两个值传递给另一个 Activity ?

android - Android Studio 中生成的 APK 大小增加

ios - 在应用程序处于后台时启动 CLLocationManager 位置更新