获取的卫星数量从Location对象

获取的卫星数量从Location对象

本文介绍了获取的卫星数量从Location对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是GPS提供商和LocationListener.onLocationChanged(地点位置)接收位置修正。
文档说,这Location.getExtras()包含一个键/值对:

I'm using a GPS provider and LocationListener.onLocationChanged(Location location) to receive location fixes.
Documentation says, that Location.getExtras() contains next key/value pair:

卫星 - 用于推导修复卫星数量

但在实践中我发现了一个空的额外的对象 - 没有任何数据存在
难道这意味着我得到了A-GPS修正,而不是GPS?

but on practice I'm getting an empty extra object - there is no any data there.
Does it means that I'm getting the A-GPS fixes and not GPS?

推荐答案

要获得使用需要实现android.location.GpsStatus.Listener和实施其方法onGpsStatusChanged的GPS引擎卫星的数量。

To get the number of satellites used by the GPS engine you need to implement android.location.GpsStatus.Listener and implement its method onGpsStatusChanged.

示例...

public void onGpsStatusChanged(int event) {
    int satellites = 0;
    int satellitesInFix = 0;
    int timetofix = locationManager.getGpsStatus(null).getTimeToFirstFix();
    Log.i(TAG, "Time to first fix = " + timetofix);
    for (GpsSatellite sat : locationManager.getGpsStatus(null).getSatellites()) {
        if(sat.usedInFix()) {
            satellitesInFix++;
        }
        satellites++;
    }
    Log.i(TAG, satellites + " Used In Last Fix ("+satellitesInFix+")");
}

这篇关于获取的卫星数量从Location对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 17:01