Example usage for android.location GnssStatus getCn0DbHz

List of usage examples for android.location GnssStatus getCn0DbHz

Introduction

In this page you can find the example usage for android.location GnssStatus getCn0DbHz.

Prototype

public float getCn0DbHz(int satIndex) 

Source Link

Document

Retrieves the carrier-to-noise density at the antenna of the satellite at the specified index in dB-Hz.

Usage

From source file:com.android.gpstest.GpsSatelliteFragment.java

@RequiresApi(api = Build.VERSION_CODES.N)
private void updateGnssStatus(GnssStatus status) {
    setStarted(true);/*  w  w  w. j  av a 2  s . co m*/

    mSnrCn0Title = mRes.getString(R.string.gps_cn0_column_label);

    if (mPrns == null) {
        /**
         * We need to allocate arrays big enough so we don't overflow them.  Per
         * https://developer.android.com/reference/android/location/GnssStatus.html#getSvid(int)
         * 255 should be enough to contain all known satellites world-wide.
         */
        final int MAX_LENGTH = 255;
        mPrns = new int[MAX_LENGTH];
        mSnrCn0s = new float[MAX_LENGTH];
        mSvElevations = new float[MAX_LENGTH];
        mSvAzimuths = new float[MAX_LENGTH];
        mConstellationType = new int[MAX_LENGTH];
        mHasEphemeris = new boolean[MAX_LENGTH];
        mHasAlmanac = new boolean[MAX_LENGTH];
        mUsedInFix = new boolean[MAX_LENGTH];
    }

    final int length = status.getSatelliteCount();
    mSvCount = 0;
    mUsedInFixCount = 0;
    while (mSvCount < length) {
        int prn = status.getSvid(mSvCount);
        mPrns[mSvCount] = prn;
        mConstellationType[mSvCount] = status.getConstellationType(mSvCount);
        mSnrCn0s[mSvCount] = status.getCn0DbHz(mSvCount);
        mSvElevations[mSvCount] = status.getElevationDegrees(mSvCount);
        mSvAzimuths[mSvCount] = status.getAzimuthDegrees(mSvCount);
        mHasEphemeris[mSvCount] = status.hasEphemerisData(mSvCount);
        mHasAlmanac[mSvCount] = status.hasAlmanacData(mSvCount);
        mUsedInFix[mSvCount] = status.usedInFix(mSvCount);
        if (status.usedInFix(mSvCount)) {
            mUsedInFixCount++;
        }

        mSvCount++;
    }

    mAdapter.notifyDataSetChanged();
}