Example usage for android.location GpsStatus getMaxSatellites

List of usage examples for android.location GpsStatus getMaxSatellites

Introduction

In this page you can find the example usage for android.location GpsStatus getMaxSatellites.

Prototype

public int getMaxSatellites() 

Source Link

Document

Returns the maximum number of satellites that can be in the satellite list that can be returned by #getSatellites() .

Usage

From source file:uk.ac.horizon.ubihelper.service.channel.GpsStatusChannel.java

public void onGpsStatusChanged(int type) {
    if (location != null) {
        GpsStatus status = location.getGpsStatus(null);
        JSONObject value = new JSONObject();
        try {//from  www .  j  a va  2 s.  c  o  m
            // event time is in nanoseconds
            value.put("timestamp", System.currentTimeMillis());
            value.put("status", type);
            value.put("maxSatellites", status.getMaxSatellites());
            value.put("timeToFirstFix", status.getTimeToFirstFix());
            JSONArray sats = new JSONArray();
            value.put("satellites", sats);
            for (GpsSatellite satellite : status.getSatellites()) {
                JSONObject s = new JSONObject();
                s.put("used", satellite.usedInFix());
                s.put("azimuth", satellite.getAzimuth());
                s.put("elevation", satellite.getElevation());
                s.put("prn", satellite.getPrn());
                s.put("snr", satellite.getSnr());
                sats.put(s);
            }
            onNewValue(value);

        } catch (JSONException e) {
            /* ignore */
        }
    }
}

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

private void updateStatus(GpsStatus status) {

    setStarted(true);// w w w .j a  v a2  s  . com
    // update the fix time regularly, since it is displaying relative time
    updateFixTime();

    Iterator<GpsSatellite> satellites = status.getSatellites().iterator();

    if (mPrns == null) {
        int length = status.getMaxSatellites();
        mPrns = new int[length];
        mSnrs = new float[length];
        mSvElevations = new float[length];
        mSvAzimuths = new float[length];
    }

    mSvCount = 0;
    mEphemerisMask = 0;
    mAlmanacMask = 0;
    mUsedInFixMask = 0;
    while (satellites.hasNext()) {
        GpsSatellite satellite = satellites.next();
        int prn = satellite.getPrn();
        int prnBit = (1 << (prn - 1));
        mPrns[mSvCount] = prn;
        mSnrs[mSvCount] = satellite.getSnr();
        mSvElevations[mSvCount] = satellite.getElevation();
        mSvAzimuths[mSvCount] = satellite.getAzimuth();
        if (satellite.hasEphemeris()) {
            mEphemerisMask |= prnBit;
        }
        if (satellite.hasAlmanac()) {
            mAlmanacMask |= prnBit;
        }
        if (satellite.usedInFix()) {
            mUsedInFixMask |= prnBit;
        }
        mSvCount++;
    }

    mAdapter.notifyDataSetChanged();
}