Example usage for android.location GpsStatus GPS_EVENT_SATELLITE_STATUS

List of usage examples for android.location GpsStatus GPS_EVENT_SATELLITE_STATUS

Introduction

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

Prototype

int GPS_EVENT_SATELLITE_STATUS

To view the source code for android.location GpsStatus GPS_EVENT_SATELLITE_STATUS.

Click Source Link

Document

Event sent periodically to report GPS satellite status.

Usage

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

public void onGpsStatusChanged(int event) {
    mStatus = mService.getGpsStatus(mStatus);

    switch (event) {
    case GpsStatus.GPS_EVENT_STARTED:
        break;/* ww  w  .  j a va  2s  . c o m*/
    case GpsStatus.GPS_EVENT_STOPPED:
        break;
    case GpsStatus.GPS_EVENT_FIRST_FIX:
        int ttff = mStatus.getTimeToFirstFix();
        if (ttff == 0) {
            mTtff = "";
        } else {
            ttff = (ttff + 500) / 1000;
            mTtff = Integer.toString(ttff) + " sec";
        }
        break;
    case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
        // Stop progress bar after the first status information is obtained
        setSupportProgressBarIndeterminateVisibility(Boolean.FALSE);
        break;
    }

    // If the user is viewing the tutorial, we don't want to clutter the status screen, so return
    if (sv != null && sv.isShown()) {
        return;
    }

    for (GpsTestListener listener : mGpsTestListeners) {
        listener.onGpsStatusChanged(event, mStatus);
    }
}

From source file:eu.basicairdata.graziano.gpslogger.GPSApplication.java

@Override
public void onGpsStatusChanged(final int event) {
    switch (event) {
    case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
        // TODO: get here the status of the GPS, and save into a GpsStatus to be used for satellites visualization;
        // Use GpsStatus getGpsStatus (GpsStatus status)
        // https://developer.android.com/reference/android/location/LocationManager.html#getGpsStatus(android.location.GpsStatus)
        updateSats();/*from w  w  w .j a va2s .co  m*/
        break;
    }
}

From source file:com.androzic.location.LocationService.java

@Override
public void onGpsStatusChanged(int event) {
    switch (event) {
    case GpsStatus.GPS_EVENT_STARTED:
        updateProvider(LocationManager.GPS_PROVIDER, true);
        updateGpsStatus(GPS_SEARCHING, 0, 0);
        break;/*w w w .  j a  va2  s.co m*/
    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;
    }
}