Java Code Examples for android.location.GpsStatus#GPS_EVENT_STARTED
The following examples show how to use
android.location.GpsStatus#GPS_EVENT_STARTED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GpsStatusMonitor.java From GravityBox with Apache License 2.0 | 6 votes |
@Override public void onGpsStatusChanged(int event) { switch (event) { case GpsStatus.GPS_EVENT_STARTED: if (DEBUG) log("onGpsStatusChanged: GPS_EVENT_STARTED"); break; case GpsStatus.GPS_EVENT_STOPPED: if (DEBUG) log("onGpsStatusChanged: GPS_EVENT_STOPPED"); if (mGpsFixed) { mGpsFixed = false; notifyGpsFixChanged(); } break; case GpsStatus.GPS_EVENT_FIRST_FIX: if (DEBUG) log("onGpsStatusChanged: GPS_EVENT_FIRST_FIX"); mGpsFixed = true; notifyGpsFixChanged(); break; } }
Example 2
Source File: GPSListenersMaker.java From apollo-DuerOS with Apache License 2.0 | 6 votes |
@Override public void onGpsStatusChanged(int event) { switch (event) { // first time fix case GpsStatus.GPS_EVENT_FIRST_FIX: break; // satellite status changed case GpsStatus.GPS_EVENT_SATELLITE_STATUS: GpsStatus gpsStatus = mLocationManager.getGpsStatus(null); int maxSatellites = gpsStatus.getMaxSatellites(); Iterator iters = gpsStatus.getSatellites().iterator(); int count = 0; while (iters.hasNext() && count <= maxSatellites) { iters.next(); count++; } mSatellitesNum = count; break; case GpsStatus.GPS_EVENT_STARTED: break; case GpsStatus.GPS_EVENT_STOPPED: break; default: break; } }
Example 3
Source File: TrackerService.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onGpsStatusChanged(int event) { switch (event) { case GpsStatus.GPS_EVENT_STARTED: case GpsStatus.GPS_EVENT_STOPPED: mHasGPSFix = false; break; case GpsStatus.GPS_EVENT_FIRST_FIX: mHasGPSFix = true; break; case GpsStatus.GPS_EVENT_SATELLITE_STATUS: mSatellitesCount = 0; for (GpsSatellite sat : mLocationManager.getGpsStatus(null).getSatellites()) { if (sat.usedInFix()) { mSatellitesCount++; } } break; } }
Example 4
Source File: GpsEventSource.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onGpsStatusChanged(int event) { switch(event) { case GpsStatus.GPS_EVENT_STARTED: case GpsStatus.GPS_EVENT_STOPPED: mHasGPSFix = false; break; case GpsStatus.GPS_EVENT_FIRST_FIX: mHasGPSFix = true; break; case GpsStatus.GPS_EVENT_SATELLITE_STATUS: break; } for (GpsEventListener listener : mListeners) { listener.onGpsStatusChanged(event); } }
Example 5
Source File: GpsConnection.java From WhereYouGo with GNU General Public License v3.0 | 5 votes |
public void onGpsStatusChanged(int event) { // Logger.i(TAG, "onGpsStatusChanged(" + event + ")"); try { if (locationManager == null) return; if (event == GpsStatus.GPS_EVENT_FIRST_FIX) { // Logger.w(TAG, "onGpsStatusChanged(" + event + "), first fix"); } else if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) { // Logger.w(TAG, "onGpsStatusChanged(" + event + "), satellite status"); if (gpsStatus == null) gpsStatus = locationManager.getGpsStatus(null); else gpsStatus = locationManager.getGpsStatus(gpsStatus); LocationState.onGpsStatusChanged(event, gpsStatus); } else if (event == GpsStatus.GPS_EVENT_STARTED) { // Logger.w(TAG, "onGpsStatusChanged(" + event + "), started"); LocationState.onGpsStatusChanged(event, null); } else if (event == GpsStatus.GPS_EVENT_STOPPED) { // Logger.w(TAG, "onGpsStatusChanged(" + event + "), stopped"); LocationState.onGpsStatusChanged(event, null); // XXX this happen for unknown reason! } } catch (Exception e) { Logger.e(TAG, "onGpsStatusChanged(" + event + ")", e); } }
Example 6
Source File: LocationState.java From WhereYouGo with GNU General Public License v3.0 | 5 votes |
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); } }
Example 7
Source File: MainActivity.java From android-location-service with Apache License 2.0 | 5 votes |
@Override public void onGpsStatusChanged(int event) { switch (event) { case GpsStatus.GPS_EVENT_STARTED: Log.d(TAG, "GPS has started."); break; case GpsStatus.GPS_EVENT_STOPPED: Log.d(TAG, "GPS has stopped."); checkLocationEnabled(); if (mBackgroundLocationService.getGoogleApiClient().isConnected() && !mLocationEnabled) { Log.d(TAG, "Disconnecting location client"); Toast.makeText(this, "Location disabled.", Toast.LENGTH_SHORT).show(); } break; } }
Example 8
Source File: GpsActivity.java From nearbydemo with Eclipse Public License 1.0 | 5 votes |
@Override public void onGpsStatusChanged(int event) { // ��ȡ��ǰ״̬ gpsstatus = locationManager.getGpsStatus(null); switch (event) { // ��һ�ζ�λʱ���¼� case GpsStatus.GPS_EVENT_FIRST_FIX: break; // ��ʼ��λ���¼� case GpsStatus.GPS_EVENT_STARTED: break; // ����GPS����״̬�¼� case GpsStatus.GPS_EVENT_SATELLITE_STATUS: Toast.makeText(GpsActivity.this, "GPS_EVENT_SATELLITE_STATUS", Toast.LENGTH_SHORT).show(); Iterable<GpsSatellite> allSatellites = gpsstatus.getSatellites(); Iterator<GpsSatellite> it = allSatellites.iterator(); int count = 0; while (it.hasNext()) { count++; } Toast.makeText(GpsActivity.this, "Satellite Count:" + count, Toast.LENGTH_SHORT).show(); break; // ֹͣ��λ�¼� case GpsStatus.GPS_EVENT_STOPPED: Log.d(TAG, "GPS_EVENT_STOPPED"); break; } }
Example 9
Source File: LocationService.java From trekarta with GNU General Public License v3.0 | 4 votes |
@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; } }
Example 10
Source File: LocationService.java From Androzic with GNU General Public License v3.0 | 4 votes |
@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; } }