android.location.GpsSatellite - java examples

Here are the examples of the java api android.location.GpsSatellite taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

24 Examples 7

19 View Complete Implementation : GpsObserver.java
Copyright Apache License 2.0
Author : davidvavra
@Override
public void onGpsStatusChanged(int event) {
    if (locationManager == null) {
        return;
    }
    if (event == GpsStatus.GPS_EVENT_FIRST_FIX) {
        if (!hasFix) {
            hasFix = true;
            mBus.post(new FirstFixEvent());
        }
    } else if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) {
        GpsStatus gpsStatus = locationManager.getGpsStatus(null);
        int all = 0;
        Iterable<GpsSatellite> satellites = gpsStatus.getSatellites();
        for (GpsSatellite ignored : satellites) {
            all++;
        }
        mBus.post(new SatellitesEvent(all));
    }
}

19 View Complete Implementation : GPS.java
Copyright Apache License 2.0
Author : jackvt93
@Override
public IterationData calculateIteration(long iteration) {
    IterationData result = IterationData.obtain();
    /* Get the number of satellites that were available in the last update. */
    int satellites = 0;
    synchronized (this) {
        if (lastStatus != null) {
            for (GpsSatellite satellite : lastStatus.getSatellites()) {
                satellites++;
            }
        }
    }
    /* Get the power data for the physical gps device. */
    GpsData power = GpsData.obtain();
    synchronized (gpsState) {
        double[] stateTimes = gpsState.getStateTimesLocked();
        int curState = gpsState.getCurrentStateLocked();
        power.init(stateTimes, curState == POWER_STATE_ON ? satellites : 0);
        gpsState.resetTimesLocked();
    }
    result.setPowerData(power);
    /* Get the power data for each uid if we have information on it. */
    if (hasUidInfo)
        synchronized (uidStates) {
            lastTime = beginTime + iterationInterval * iteration;
            for (int i = 0; i < uidStates.size(); i++) {
                int uid = uidStates.keyAt(i);
                GpsStateKeeper state = uidStates.valueAt(i);
                double[] stateTimes = state.getStateTimesLocked();
                int curState = state.getCurrentStateLocked();
                GpsData uidPower = GpsData.obtain();
                uidPower.init(stateTimes, curState == POWER_STATE_ON ? satellites : 0);
                state.resetTimesLocked();
                result.addUidPowerData(uid, uidPower);
                /*
					 * Remove state information for uids no longer using the
					 * gps.
					 */
                if (curState == POWER_STATE_OFF) {
                    uidStates.remove(uid);
                    i--;
                }
            }
        }
    return result;
}

19 View Complete Implementation : HookLocationFaker.java
Copyright MIT License
Author : jinsen47
private static String satelliteToString(GpsSatellite s) {
    StringBuilder sb = new StringBuilder();
    if (s != null) {
        sb.append("GpsSatellite[" + "usedInFix = " + s.usedInFix() + ", " + "hasAlmanac = " + s.hasAlmanac() + ", " + "hasEphemeris = " + s.hasEphemeris() + ", " + "prn = " + s.getPrn() + ", " + "snr = " + s.getSnr() + ", " + "elevation = " + s.getElevation() + ", " + "azimuth = " + s.getAzimuth() + "]");
    } else {
        sb.append("GpsSatellite[null]");
    }
    return sb.toString();
}

19 View Complete Implementation : GpsStatus.java
Copyright GNU General Public License v3.0
Author : jonasoreland
@Override
public void onGpsStatusChanged(int event) {
    if (locationManager == null)
        return;
    android.location.GpsStatus gpsStatus;
    try {
        gpsStatus = locationManager.getGpsStatus(null);
    } catch (SecurityException ex) {
        gpsStatus = null;
    }
    if (gpsStatus == null)
        return;
    int cnt0 = 0, cnt1 = 0;
    Iterable<GpsSatellite> list = gpsStatus.getSatellites();
    for (GpsSatellite satellite : list) {
        cnt0++;
        if (satellite.usedInFix()) {
            cnt1++;
        }
    }
    mKnownSatellites = cnt0;
    mUsedInLastFixSatellites = cnt1;
    if (listener != null)
        listener.onTick();
}

19 View Complete Implementation : LocationProviderAndroid.java
Copyright MIT License
Author : platypii
@Override
public void onGpsStatusChanged(int event) {
    switch(event) {
        case GpsStatus.GPS_EVENT_STARTED:
            Log.i(TAG, "GPS started");
            break;
        case GpsStatus.GPS_EVENT_STOPPED:
            Log.i(TAG, "GPS stopped");
            break;
        case GpsStatus.GPS_EVENT_FIRST_FIX:
            Log.i(TAG, "GPS first fix");
            break;
        case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
            if (manager != null) {
                try {
                    gpsStatus = manager.getGpsStatus(gpsStatus);
                    final Iterable<GpsSatellite> satellites = gpsStatus.getSatellites();
                    int count = 0;
                    int used = 0;
                    for (GpsSatellite sat : satellites) {
                        count++;
                        if (sat.usedInFix()) {
                            used++;
                        }
                    }
                    // if (satellitesInView != count || satellitesUsed != used) {
                    // Log.v(TAG, "Satellite Status: " + satellitesUsed + "/" + satellitesInView);
                    // }
                    satellitesInView = count;
                    satellitesUsed = used;
                } catch (SecurityException e) {
                    Exceptions.report(e);
                }
            }
    }
}

19 View Complete Implementation : SatelliteDataCollector.java
Copyright MIT License
Author : sussexwearlab
private void logSatelliteInfo(Iterable<GpsSatellite> gpsSatellites) {
    int satCounter = 0;
    // System nanoseconds since boot, including time spent in sleep.
    long nanoTime = SystemClock.elapsedRealtimeNanos() + mNanosOffset;
    // System local time in millis
    long currentMillis = (new Date()).getTime();
    String message = String.format("%s", currentMillis) + ";" + String.format("%s", nanoTime) + ";" + String.format("%s", mNanosOffset);
    for (GpsSatellite satellite : gpsSatellites) {
        satCounter++;
        // PRN (pseudo-random number) for the satellite.
        int prn = satellite.getPrn();
        // Signal to noise ratio for the satellite.
        float snr = satellite.getSnr();
        // Azimuth of the satellite in degrees.
        float azimuth = satellite.getAzimuth();
        // Elevation of the satellite in degrees.
        float elevation = satellite.getElevation();
        message += ";" + prn + ";" + snr + ";" + azimuth + ";" + elevation;
    }
    message += ";" + Integer.toString(satCounter);
    logger.log(message);
    logger.log(System.lineSeparator());
}

18 View Complete Implementation : GpsSnrView.java
Copyright GNU General Public License v3.0
Author : mvglasow
/**
 * Initializes the SNR grid.
 * <p>
 * This method iterates through {@link #mSats} to determine which ranges of
 * NMEA IDs will be drawn.
 */
protected void initializeGrid() {
    // iterate through list to find out how many bars to draw
    if (mSats != null)
        for (GpsSatellite sat : mSats) {
            int prn = sat.getPrn();
            if (prn < 1) {
                Log.wtf(TAG, String.format("Got satellite with invalid NMEA ID %d", prn));
            } else if (prn <= 32) {
                draw_1_32 = true;
            } else if (prn <= 54) {
                draw_33_54 = true;
            } else if (prn <= 64) {
                // most likely an extended SBAS range, display the lower range, too
                draw_33_54 = true;
                draw_55_64 = true;
            } else if (prn <= 88) {
                draw_65_88 = true;
            } else if (prn <= 96) {
                // most likely an extended GLONreplaced range, display the lower range, too
                draw_65_88 = true;
                draw_89_96 = true;
            } else if (prn <= 192) {
                // TODO: do we really want to enable this huge 96-sat block?
                draw_97_192 = true;
                Log.w(TAG, String.format("Got satellite with NMEA ID %d (from the huge unreplacedigned 97-192 range)", prn));
            } else if (prn <= 195) {
                draw_193_195 = true;
            } else if (prn <= 200) {
                // most likely an extended QZSS range, display the lower range, too
                draw_193_195 = true;
                draw_196_200 = true;
            } else if (prn <= 235) {
                draw_201_235 = true;
            } else if (prn <= 300) {
                // TODO: same as above, do we really want to enable this?
                draw_236_300 = true;
            } else if (prn <= 336) {
                draw_301_336 = true;
            } else {
                Log.w(TAG, String.format("Got satellite with NMEA ID %d, possibly unsupported system", prn));
            }
        }
    /*
		 * If we didn't get any valid ranges, display at least the GPS range.
		 * No need to check for extended ranges here - if they get drawn, so
		 * will their corresponding base range.
		 */
    if (!(draw_1_32 || draw_33_54 || draw_65_88 || draw_97_192 || draw_193_195 || draw_201_235 || draw_236_300 || draw_301_336))
        draw_1_32 = true;
}

18 View Complete Implementation : GpsSatelliteTest.java
Copyright MIT License
Author : pivotal-legacy
@TestTargetClreplaced(GpsSatellite.clreplaced)
public clreplaced GpsSatelliteTest extends AndroidTestCase {

    private GpsSatellite mGpsSatellite;

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        LocationManager lm = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);
        GpsStatus gpsStatus = lm.getGpsStatus(null);
        Iterator<GpsSatellite> iterator = gpsStatus.getSatellites().iterator();
        if (iterator.hasNext()) {
            mGpsSatellite = iterator.next();
        }
    }

    @TestTargetNew(level = TestLevel.COMPLETE, method = "getAzimuth", args = {})
    public void testGetAzimuth() {
        if (mGpsSatellite != null) {
            replacedertTrue(mGpsSatellite.getAzimuth() >= 0 && mGpsSatellite.getAzimuth() <= 360);
        }
    }

    @TestTargetNew(level = TestLevel.COMPLETE, method = "getElevation", args = {})
    public void testGetElevation() {
        if (mGpsSatellite != null) {
            replacedertTrue(mGpsSatellite.getElevation() >= 0 && mGpsSatellite.getElevation() <= 90);
        }
    }

    @TestTargetNew(level = TestLevel.COMPLETE, method = "getPrn", args = {})
    public void testGetPrn() {
        if (mGpsSatellite != null) {
            // make sure there is no exception.
            mGpsSatellite.getPrn();
        }
    }

    @TestTargetNew(level = TestLevel.COMPLETE, method = "getSnr", args = {})
    public void testGetSnr() {
        if (mGpsSatellite != null) {
            // make sure there is no exception.
            mGpsSatellite.getSnr();
        }
    }

    @TestTargetNew(level = TestLevel.COMPLETE, method = "hasAlmanac", args = {})
    public void testHasAlmanac() {
        if (mGpsSatellite != null) {
            // make sure there is no exception.
            mGpsSatellite.hasAlmanac();
        }
    }

    @TestTargetNew(level = TestLevel.COMPLETE, method = "hasEphemeris", args = {})
    public void testHasEphemeris() {
        if (mGpsSatellite != null) {
            // make sure there is no exception.
            mGpsSatellite.hasEphemeris();
        }
    }

    @TestTargetNew(level = TestLevel.COMPLETE, method = "usedInFix", args = {})
    public void testUsedInFix() {
        if (mGpsSatellite != null) {
            // make sure there is no exception.
            mGpsSatellite.usedInFix();
        }
    }
}

18 View Complete Implementation : GpsSatelliteSubject.java
Copyright Apache License 2.0
Author : pkware
/**
 * Propositions for {@link GpsSatellite} subjects.
 */
public clreplaced GpsSatelliteSubject extends Subject {

    @Nullable
    private final GpsSatellite actual;

    public GpsSatelliteSubject(@Nonnull FailureMetadata failureMetadata, @Nullable GpsSatellite actual) {
        super(failureMetadata, actual);
        this.actual = actual;
    }

    public void hasAzimuth(float azimuth, float tolerance) {
        check("getAzimuth()").that(actual.getAzimuth()).isWithin(tolerance).of(azimuth);
    }

    public void hasElevation(float elevation, float tolerance) {
        check("getElevation()").that(actual.getElevation()).isWithin(tolerance).of(elevation);
    }

    public void hasPrn(int prn) {
        check("getPrn()").that(actual.getPrn()).isEqualTo(prn);
    }

    public void hreplacednr(float snr, float tolerance) {
        check("getSnr()").that(actual.getSnr()).isWithin(tolerance).of(snr);
    }

    public void hasAlmanac() {
        check("hasAlmanac()").that(actual.hasAlmanac()).isTrue();
    }

    public void hasNoAlmanac() {
        check("hasAlmanac()").that(actual.hasAlmanac()).isFalse();
    }

    public void hasEphemeris() {
        check("hasEphemeris()").that(actual.hasEphemeris()).isTrue();
    }

    public void hasNotEphemeris() {
        check("hasEphemeris()").that(actual.hasEphemeris()).isFalse();
    }

    public void isUsedInFix() {
        check("usedInFix()").that(actual.usedInFix()).isTrue();
    }

    public void isNotUsedInFix() {
        check("usedInFix()").that(actual.usedInFix()).isFalse();
    }
}

16 View Complete Implementation : PasvLocListenerService.java
Copyright GNU General Public License v3.0
Author : mvglasow
@Override
public void onGpsStatusChanged(int event) {
    GpsStatus status = mLocationManager.getGpsStatus(null);
    int satsUsed = 0;
    Iterable<GpsSatellite> sats = status.getSatellites();
    for (GpsSatellite sat : sats) {
        if (sat.usedInFix()) {
            satsUsed++;
        }
    }
    if (satsUsed == 0) {
        if (mStatus != GPS_INACTIVE)
            mStatus = GPS_SEARCH;
        showStatusNoLocation();
    }
}

16 View Complete Implementation : MainActivity.java
Copyright GNU General Public License v3.0
Author : mvglasow
/**
 * Called when the status of the GPS changes. Updates GPS display.
 */
public void onGpsStatusChanged(int event) {
    GpsStatus status = locationManager.getGpsStatus(null);
    int satsInView = 0;
    int satsUsed = 0;
    Iterable<GpsSatellite> sats = status.getSatellites();
    for (GpsSatellite sat : sats) {
        satsInView++;
        if (sat.usedInFix()) {
            satsUsed++;
        }
    }
    if (gpsSectionFragment != null) {
        gpsSectionFragment.onGpsStatusChanged(status, satsInView, satsUsed, sats);
    }
    if (mapSectionFragment != null) {
        mapSectionFragment.onGpsStatusChanged(status, satsInView, satsUsed, sats);
    }
}

15 View Complete Implementation : GPSListener.java
Copyright GNU General Public License v3.0
Author : rcgroot
@Override
public synchronized void onGpsStatusChanged(int event) {
    switch(event) {
        case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
            if (mStatusMonitor) {
                GpsStatus status = mLocationManager.getGpsStatus(null);
                mLoggerNotification.numberOfSatellites = 0;
                Iterable<GpsSatellite> list = status.getSatellites();
                for (GpsSatellite satellite : list) {
                    if (satellite.usedInFix()) {
                        mLoggerNotification.numberOfSatellites++;
                    }
                }
                mLoggerNotification.updateLogging(mPrecision, mLoggingState, mStatusMonitor, mTrackId);
            }
            break;
        case GpsStatus.GPS_EVENT_STOPPED:
            break;
        case GpsStatus.GPS_EVENT_STARTED:
            break;
        default:
            break;
    }
}

14 View Complete Implementation : MainActivity.java
Copyright GNU General Public License v2.0
Author : flyingrub
@Override
public void onGpsStatusChanged(int event) {
    switch(event) {
        case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
            GpsStatus gpsStatus = mLocationManager.getGpsStatus(null);
            int satsInView = 0;
            int satsUsed = 0;
            Iterable<GpsSatellite> sats = gpsStatus.getSatellites();
            for (GpsSatellite sat : sats) {
                satsInView++;
                if (sat.usedInFix()) {
                    satsUsed++;
                }
            }
            satellite.setText(String.valueOf(satsUsed) + "/" + String.valueOf(satsInView));
            if (satsUsed == 0) {
                fab.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_play));
                data.setRunning(false);
                status.setText("");
                stopService(new Intent(getBaseContext(), GpsServices.clreplaced));
                fab.setVisibility(View.INVISIBLE);
                refresh.setVisibility(View.INVISIBLE);
                accuracy.setText("");
                status.setText(getResources().getString(R.string.waiting_for_fix));
                firstfix = true;
            }
            break;
        case GpsStatus.GPS_EVENT_STOPPED:
            if (!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                showGpsDisabledDialog();
            }
            break;
        case GpsStatus.GPS_EVENT_FIRST_FIX:
            break;
    }
}

14 View Complete Implementation : GpsSnrView.java
Copyright GNU General Public License v3.0
Author : mvglasow
/**
 * Redraws the SNR view.
 * <p>
 * This method is called whenever the view needs to be redrawn. Besides the
 * usual cases of view creation/recreation, this also occurs when the
 * {@link #showSats(Iterable)} has been called to indicate new SNR data is
 * available.
 */
@Override
protected void onDraw(Canvas canvas) {
    initializeGrid();
    // draw the SNR bars
    if (mSats != null)
        for (GpsSatellite sat : mSats) drawSat(canvas, sat.getPrn(), sat.getSnr(), sat.usedInFix());
    // draw the grid on top
    drawGrid(canvas);
}

14 View Complete Implementation : DiagnosticsActivity.java
Copyright Apache License 2.0
Author : osmdroid
private void probeGps() {
    StringBuilder sb = new StringBuilder();
    if (currentLocation != null) {
        sb.append("Current Location:\n");
        sb.append(currentLocation.getLareplacedude()).append(",").append(currentLocation.getLongitude()).append("\n");
        sb.append("Alt ").append(currentLocation.getAlreplacedude()).append("\n");
        sb.append("Accuracy ").append(currentLocation.getAccuracy()).append("\n");
        sb.append("Bearing ").append(currentLocation.getBearing()).append("\n");
        sb.append("Speed ").append(currentLocation.getSpeed()).append("\n\n");
    }
    try {
        if (gpsStatus != null) {
            Iterator<GpsSatellite> iterator = gpsStatus.getSatellites().iterator();
            while (iterator.hasNext()) {
                GpsSatellite next = iterator.next();
                sb.append("Sat PRN " + next.getPrn() + " Elevation " + next.getElevation() + " Azimuth " + next.getAzimuth() + "SNR " + next.getSnr()).append("\n");
            }
        }
    } catch (Exception e) {
        sb.append(e.toString());
    }
    output.setText(sb.toString());
}

14 View Complete Implementation : SensorDataController.java
Copyright Apache License 2.0
Author : renard314
@Override
public void onGpsStatusChanged(final int event) {
    boolean isGPSFix = false;
    switch(event) {
        case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
            mSatelliteNumber = 0;
            GpsStatus stat = mLocationManager.getGpsStatus(null);
            Iterable<GpsSatellite> sats = stat.getSatellites();
            for (GpsSatellite sat : sats) {
                if (sat.usedInFix()) {
                    mSatelliteNumber++;
                }
            }
            if (mLastLocation != null)
                isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000;
            if (isGPSFix) {
                mGPSLight.setLightColor(getGPSColor(mSatelliteNumber));
            } else {
                mGPSLight.setLightColor(Color.RED);
            }
            break;
        case GpsStatus.GPS_EVENT_FIRST_FIX:
            isGPSFix = true;
            mGPSLight.setLightColor(getGPSColor(mSatelliteNumber));
            break;
    }
}

13 View Complete Implementation : LocationService.java
Copyright GNU General Public License v3.0
Author : andreynovikov
@Override
public void onGpsStatusChanged(int event) {
    if (enableMockLocations)
        return;
    switch(event) {
        case GpsStatus.GPS_EVENT_STARTED:
            updateProvider(LocationManager.GPS_PROVIDER, true);
            updateGpsStatus(GPS_SEARCHING, 0, 0);
            break;
        case GpsStatus.GPS_EVENT_FIRST_FIX:
            isContinous = false;
            break;
        case GpsStatus.GPS_EVENT_STOPPED:
            tearTrack();
            updateGpsStatus(GPS_OFF, 0, 0);
            updateProvider(LocationManager.GPS_PROVIDER, false);
            break;
        case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
            if (locationManager == null)
                return;
            GpsStatus gpsStatus = locationManager.getGpsStatus(null);
            Iterator<GpsSatellite> it = gpsStatus.getSatellites().iterator();
            int tSats = 0;
            int fSats = 0;
            while (it.hasNext()) {
                tSats++;
                GpsSatellite sat = (GpsSatellite) it.next();
                if (sat.usedInFix())
                    fSats++;
            }
            if (SystemClock.elapsedRealtime() - lastLocationMillis < 3000) {
                updateGpsStatus(GPS_OK, fSats, tSats);
            } else {
                tearTrack();
                updateGpsStatus(GPS_SEARCHING, fSats, tSats);
            }
            break;
    }
}

13 View Complete Implementation : MainActivity.java
Copyright Apache License 2.0
Author : MichaelVL
public void onGpsStatusChanged(int event) {
    boolean statchg = false;
    switch(event) {
        case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
            GpsStatus gstat = mLocationManager.getGpsStatus(null);
            if (gstat != null) {
                Iterable<GpsSatellite> satellites = gstat.getSatellites();
                Iterator<GpsSatellite> sat = satellites.iterator();
                int num = 0, used = 0;
                while (sat.hasNext()) {
                    num++;
                    GpsSatellite satellite = sat.next();
                    if (satellite.usedInFix()) {
                        used++;
                    }
                }
                if (mG.mSatelitesVisible != num || mG.mSatelitesUsed != used)
                    statchg = true;
                mG.mSatelitesVisible = num;
                mG.mSatelitesUsed = used;
            }
            break;
    }
    if (statchg)
        mapView.postInvalidate();
}

13 View Complete Implementation : PasvLocListenerService.java
Copyright GNU General Public License v3.0
Author : mvglasow
@Override
public void onLocationChanged(Location location) {
    if (!location.getProvider().equals(LocationManager.GPS_PROVIDER))
        return;
    if (mNotifyFix && (mStatus != GPS_INACTIVE)) {
        mStatus = GPS_FIX;
        GpsStatus status = mLocationManager.getGpsStatus(null);
        int satsInView = 0;
        int satsUsed = 0;
        Iterable<GpsSatellite> sats = status.getSatellites();
        for (GpsSatellite sat : sats) {
            satsInView++;
            if (sat.usedInFix()) {
                satsUsed++;
            }
        }
        double lat = Math.abs(location.getLareplacedude());
        double lon = Math.abs(location.getLongitude());
        String ns = (location.getLareplacedude() > 0) ? getString(R.string.value_N) : (location.getLareplacedude() < 0) ? getString(R.string.value_S) : "";
        String ew = (location.getLongitude() > 0) ? getString(R.string.value_E) : (location.getLongitude() < 0) ? getString(R.string.value_W) : "";
        String replacedle = "";
        if (prefCoord == Const.KEY_PREF_COORD_DECIMAL) {
            replacedle = String.format("%.5f%s%s %.5f%s%s", lat, getString(R.string.unit_degree), ns, lon, getString(R.string.unit_degree), ew);
        } else if (prefCoord == Const.KEY_PREF_COORD_MIN) {
            double decY = lat;
            double degY = (int) decY;
            double minY = Math.abs(60.0 * (decY - degY));
            double decX = lon;
            double degX = (int) decX;
            double minX = Math.abs(60.0 * (decX - degX));
            replacedle = String.format("%.0f%s %.3f' %s %.0f%s %.3f' %s", degY, getString(R.string.unit_degree), minY + /*rounding*/
            0.0005, ns, degX, getString(R.string.unit_degree), minX + /*rounding*/
            0.0005, ew);
        } else if (prefCoord == Const.KEY_PREF_COORD_SEC) {
            double decY = lat;
            double degY = (int) decY;
            double tmp = 60.0 * (decY - degY);
            double minY = (int) Math.abs(tmp);
            double secY = Math.abs(60.0 * (tmp - minY));
            double decX = lon;
            double degX = (int) decX;
            tmp = 60.0 * (decX - degX);
            double minX = (int) Math.abs(tmp);
            double secX = Math.abs(60.0 * (tmp - minX));
            replacedle = String.format("%.0f%s %.0f' %.1f\" %s %.0f%s %.0f' %.1f\" %s", degY, getString(R.string.unit_degree), minY, secY + /*rounding*/
            0.05, ns, degX, getString(R.string.unit_degree), minX, secX + /*rounding*/
            0.05, ew);
        } else if (prefCoord == Const.KEY_PREF_COORD_MGRS) {
            replacedle = new LatLng(location.getLareplacedude(), location.getLongitude()).toMGRSRef().toString(MGRSRef.PRECISION_1M);
        } else if (prefCoord == Const.KEY_PREF_COORD_UTM) {
            replacedle = UTM.lat_lon_to_utm(location.getLareplacedude(), location.getLongitude(), this.getApplicationContext());
        }
        String text = "";
        if (location.hasAlreplacedude()) {
            text = text + String.format("%.0f%s", (location.getAlreplacedude() * (prefUnitType ? 1 : 3.28084)), getString(((prefUnitType) ? R.string.unit_meter : R.string.unit_feet)));
        }
        if (location.hreplacedpeed()) {
            text = text + (text.equals("") ? "" : ", ") + String.format("%.0f%s", (location.getSpeed() * (prefKnots ? 1.943844 : prefUnitType ? 3.6 : 2.23694)), getString(((prefKnots) ? R.string.unit_kn : (prefUnitType) ? R.string.unit_km_h : R.string.unit_mph)));
        }
        if (location.hasAccuracy()) {
            text = text + (text.equals("") ? "" : ", ") + String.format("\u03b5 = %.0f%s", (location.getAccuracy() * (prefUnitType ? 1 : 3.28084)), getString(((prefUnitType) ? R.string.unit_meter : R.string.unit_feet)));
        }
        text = text + (text.equals("") ? "" : ", ") + String.format("%d/%d", satsUsed, satsInView);
        text = text + (text.equals("") ? "" : ",\n") + String.format("TTFF %d s", status.getTimeToFirstFix() / 1000);
        mBuilder.setSmallIcon(R.drawable.ic_stat_notify_location);
        mBuilder.setContentreplacedle(replacedle);
        mBuilder.setContentText(text);
        mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(text));
        startForeground(ONGOING_NOTIFICATION, mBuilder.build());
    } else {
        stopForeground(true);
    }
}

12 View Complete Implementation : LocationState.java
Copyright GNU General Public License v3.0
Author : cgeo
static void onGpsStatusChanged(int event, GpsStatus gpsStatus) {
    if (mListeners == null || mListeners.size() == 0)
        return;
    if (event == GpsStatus.GPS_EVENT_STARTED || event == GpsStatus.GPS_EVENT_STOPPED) {
        for (int i = 0; i < mListeners.size(); i++) {
            mListeners.get(i).onStatusChanged(LocationManager.GPS_PROVIDER, event == GpsStatus.GPS_EVENT_STARTED ? 2 : 1, null);
        }
    } else if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) {
        ArrayList<SatellitePosition> pos = null;
        if (gpsStatus != null) {
            pos = new ArrayList<>();
            Iterator<GpsSatellite> enuSat = gpsStatus.getSatellites().iterator();
            // clear sats count
            mSatsCount.x = 0;
            mSatsCount.y = 0;
            while (enuSat.hasNext()) {
                GpsSatellite sat = enuSat.next();
                // pos.add(enuPos.nextElement());
                SatellitePosition satPos = new SatellitePosition();
                satPos.azimuth = sat.getAzimuth();
                satPos.elevation = sat.getElevation();
                satPos.prn = sat.getPrn();
                satPos.snr = (int) sat.getSnr();
                satPos.fixed = sat.usedInFix();
                if (satPos.fixed)
                    mSatsCount.x++;
                mSatsCount.y++;
                pos.add(satPos);
            }
        }
        postGpsSatelliteChange(pos);
    }
}

12 View Complete Implementation : GpsStatusRecord.java
Copyright GNU General Public License v3.0
Author : labexp
@Override
public void onGpsStatusChanged(int event) {
    // Update GPS Status image according to event
    ImageView imgSatIndicator = (ImageView) findViewById(R.id.gpsstatus_record_imgSatIndicator);
    switch(event) {
        case GpsStatus.GPS_EVENT_FIRST_FIX:
            imgSatIndicator.setImageResource(R.drawable.sat_indicator_0);
            activity.onGpsEnabled();
            break;
        case GpsStatus.GPS_EVENT_STARTED:
            imgSatIndicator.setImageResource(R.drawable.sat_indicator_unknown);
            break;
        case GpsStatus.GPS_EVENT_STOPPED:
            imgSatIndicator.setImageResource(R.drawable.sat_indicator_off);
            activity.onGpsDisabled();
            break;
        case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
            // first of all we check if the time from the last used fix to the current fix is greater than the logging interval
            if ((event != GpsStatus.GPS_EVENT_SATELLITE_STATUS) || (lastGPSTimestampStatus + gpsLoggingInterval) < System.currentTimeMillis()) {
                // save the time of this fix
                lastGPSTimestampStatus = System.currentTimeMillis();
                if (ContextCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                    break;
                }
                GpsStatus status = lmgr.getGpsStatus(null);
                satCount = 0;
                fixCount = 0;
                // Count active satellites
                for (GpsSatellite sat : status.getSatellites()) {
                    satCount++;
                    if (sat.usedInFix()) {
                        fixCount++;
                    }
                }
                // Count how many bars should we draw
                int nbBars = 0;
                for (int i = 0; i < SAT_INDICATOR_TRESHOLD.length; i++) {
                    if (fixCount >= SAT_INDICATOR_TRESHOLD[i]) {
                        nbBars = i;
                    }
                }
                Log.v(TAG, "Found " + satCount + " satellites. " + fixCount + " used in fix. Will draw " + nbBars + " bars.");
                imgSatIndicator.setImageResource(getResources().getIdentifier("drawable/sat_indicator_" + nbBars, null, OSMTracker.clreplaced.getPackage().getName()));
                if (fixCount == 0 && gpsActive) {
                    activity.onGpsDisabled();
                    gpsActive = false;
                }
                if (!gpsActive) {
                    // we set the text field (since nobody else does
                    TextView tvAccuracy = (TextView) findViewById(R.id.gpsstatus_record_tvAccuracy);
                    tvAccuracy.setText(getResources().getString(R.string.various_waiting_gps_fix).replace("{0}", Long.toString(fixCount)).replace("{1}", Long.toString(satCount)));
                }
            }
            break;
    }
}

11 View Complete Implementation : LocationService.java
Copyright GNU General Public License v3.0
Author : andreynovikov
@Override
public void onGpsStatusChanged(int event) {
    if (enableMockLocations && BuildConfig.DEBUG)
        return;
    switch(event) {
        case GpsStatus.GPS_EVENT_STARTED:
            mGpsStatus = GPS_SEARCHING;
            mTSats = 0;
            mFSats = 0;
            updateGpsStatus();
            break;
        case GpsStatus.GPS_EVENT_FIRST_FIX:
            mContinuous = false;
            break;
        case GpsStatus.GPS_EVENT_STOPPED:
            tearTrack();
            mGpsStatus = GPS_OFF;
            mTSats = 0;
            mFSats = 0;
            updateGpsStatus();
            break;
        case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
            if (mLocationManager == null)
                return;
            try {
                GpsStatus status = mLocationManager.getGpsStatus(null);
                Iterator<GpsSatellite> it = status.getSatellites().iterator();
                mTSats = 0;
                mFSats = 0;
                while (it.hasNext()) {
                    mTSats++;
                    GpsSatellite sat = it.next();
                    if (sat.usedInFix())
                        mFSats++;
                }
                if (mLastLocationMillis >= 0) {
                    if (SystemClock.elapsedRealtime() - mLastLocationMillis < 3000) {
                        mGpsStatus = GPS_OK;
                    } else {
                        if (mContinuous)
                            tearTrack();
                        mGpsStatus = GPS_SEARCHING;
                    }
                }
                updateGpsStatus();
            } catch (SecurityException e) {
                logger.error("Failed to update gps status", e);
            }
            break;
    }
}

9 View Complete Implementation : GpsStatusView.java
Copyright GNU General Public License v3.0
Author : mvglasow
@Override
protected void onDraw(Canvas canvas) {
    int cx = mW / 2;
    int cy = mH / 2;
    // Log.d("GpsStatusView", String.format("Drawing on a %dx%d canvas", w, h));
    canvas.translate(cx, cy);
    canvas.rotate(-mRotation);
    canvas.drawCircle(0, 0, mW * 0.37125f, gridBorderPaint);
    canvas.drawLine(-mW * 0.405f, 0, mW * 0.405f, 0, gridPaint);
    canvas.drawLine(0, -mH * 0.405f, 0, mH * 0.405f, gridPaint);
    canvas.drawCircle(0, 0, mW * 0.405f, gridPaint);
    canvas.drawCircle(0, 0, mW * 0.27f, gridPaint);
    canvas.drawCircle(0, 0, mW * 0.135f, gridPaint);
    canvas.drawPath(northArrow, northPaint);
    canvas.drawTextOnPath(((Activity) getContext()).getString(R.string.value_N), labelPathN, 0, -labelPaint.descent(), labelPaint);
    canvas.drawTextOnPath(((Activity) getContext()).getString(R.string.value_S), labelPathS, 0, -labelPaint.descent(), labelPaint);
    canvas.drawTextOnPath(((Activity) getContext()).getString(R.string.value_E), labelPathE, 0, -labelPaint.descent(), labelPaint);
    canvas.drawTextOnPath(((Activity) getContext()).getString(R.string.value_W), labelPathW, 0, -labelPaint.descent(), labelPaint);
    if (mSats != null) {
        for (GpsSatellite sat : mSats) {
            drawSat(canvas, sat.getPrn(), sat.getAzimuth(), sat.getElevation(), sat.getSnr(), sat.usedInFix());
        }
    }
}

6 View Complete Implementation : JSONHelper.java
Copyright Apache License 2.0
Author : Esri
/**
 * Converts GpsStatus into JSON.
 * @param gpsStatus Send a GpsStatus whenever the GPS fires
 * @return JSON representation of the satellite data
 */
public static String satelliteDataJSON(GpsStatus gpsStatus) {
    final Calendar calendar = Calendar.getInstance();
    final JSONObject json = new JSONObject();
    try {
        json.put("provider", SATELLITE_PROVIDER);
        json.put("timestamp", calendar.getTimeInMillis());
        if (gpsStatus.getSatellites() != null) {
            int count = 0;
            final int timeToFirstFix = gpsStatus.getTimeToFirstFix();
            for (GpsSatellite sat : gpsStatus.getSatellites()) {
                final JSONObject satelliteInfo = new JSONObject();
                satelliteInfo.put("PRN", sat.getPrn());
                satelliteInfo.put("timeToFirstFix", timeToFirstFix);
                satelliteInfo.put("usedInFix", sat.usedInFix());
                satelliteInfo.put("azimuth", sat.getAzimuth());
                satelliteInfo.put("elevation", sat.getElevation());
                satelliteInfo.put("hasEphemeris", sat.hasEphemeris());
                satelliteInfo.put("hasAlmanac", sat.hasAlmanac());
                satelliteInfo.put("SNR", sat.getSnr());
                json.put(Integer.toString(count), satelliteInfo);
                count++;
            }
        }
    } catch (JSONException exc) {
        logJSONException(exc);
    }
    return json.toString();
}