Example usage for android.location GnssStatus getSvid

List of usage examples for android.location GnssStatus getSvid

Introduction

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

Prototype

public int getSvid(int satIndex) 

Source Link

Document

Gets the identification number for the satellite at the specific index.

Usage

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

@RequiresApi(api = Build.VERSION_CODES.N)
private void updateGnssStatus(GnssStatus status) {
    setStarted(true);//from w  ww  .  ja v  a2 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();
}