android.location.GpsStatus Java Examples
The following examples show how to use
android.location.GpsStatus.
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: GpsStatusInfo.java From geopaparazzi with GNU General Public License v3.0 | 6 votes |
/** * Checks if there fix is still there based on the last picked location. * * @param hasFix fix state previous to the check. * @param lastLocationUpdateMillis the millis of the last picked location. * @param event the Gps status event triggered. * @return <code>true</code>, if it has fix. */ @SuppressWarnings("nls") public static boolean checkFix(boolean hasFix, long lastLocationUpdateMillis, int event) { switch (event) { case GpsStatus.GPS_EVENT_SATELLITE_STATUS: long diff = SystemClock.elapsedRealtime() - lastLocationUpdateMillis; if (GPLog.LOG_ABSURD) GPLog.addLogEntry("GPSSTATUSINFO", "gps event diff: " + diff); if (diff < FIX_TIME_INTERVAL_CHECK) { if (!hasFix) { hasFix = true; } } else { if (hasFix) { hasFix = false; } } break; } return hasFix; }
Example #2
Source File: LocationManagerProxy.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
public GpsStatus getGpsStatus(GpsStatus gpsstatus) { LocationManager locationmanager; GpsStatus gpsstatus1; GpsStatus gpsstatus2; try { locationmanager = a; } catch (Throwable throwable) { throwable.printStackTrace(); return null; } gpsstatus1 = null; if (locationmanager == null) { break MISSING_BLOCK_LABEL_26; } gpsstatus2 = a.getGpsStatus(gpsstatus); gpsstatus1 = gpsstatus2; return gpsstatus1; }
Example #3
Source File: AndroidLocationManager.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
public void onGpsStatusChanged(int event) { boolean isGPSFix = false; switch (event) { case GpsStatus.GPS_EVENT_SATELLITE_STATUS: if (lastLocation != null) { isGPSFix = (SystemClock.elapsedRealtime() - lastLocationMillis) < 10000; } if (isGPSFix) { // A fix has been acquired. setLocationManagerStatus(AVAILABLE); } else { // The fix has been lost. setLocationManagerStatus(TEMPORARILY_UNAVAILABLE); } break; case GpsStatus.GPS_EVENT_FIRST_FIX: setLocationManagerStatus(AVAILABLE); break; } }
Example #4
Source File: e.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
private void b() { m = 0; l = 0; GpsStatus gpsstatus = b.getGpsStatus(null); if (gpsstatus != null) { int i1 = gpsstatus.getMaxSatellites(); Iterator iterator = gpsstatus.getSatellites().iterator(); if (iterator != null) { while (iterator.hasNext() && l <= i1) { l = 1 + l; if (((GpsSatellite)iterator.next()).usedInFix()) { m = 1 + m; } } } } }
Example #5
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 #6
Source File: LocationHelper.java From RxAndroidBootstrap with Apache License 2.0 | 6 votes |
public void onGpsStatusChanged(int event) { if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) { try { // Check number of satellites in list to determine fix state GpsStatus status = myLocationManager.getGpsStatus(null); Iterable<GpsSatellite> satellites = status.getSatellites(); sat_count = 0; Iterator<GpsSatellite> satI = satellites.iterator(); while (satI.hasNext()) { GpsSatellite satellite = satI.next(); Log.d(LogUtils.generateTag(this), "Satellite: snr=" + satellite.getSnr() + ", elevation=" + satellite.getElevation()); sat_count++; } } catch (Exception e) { e.printStackTrace(); sat_count = min_gps_sat_count + 1; } Log.d(LogUtils.generateTag(this), "#### sat_count = " + sat_count); } }
Example #7
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 #8
Source File: LocationHelper.java From MVPAndroidBootstrap with Apache License 2.0 | 6 votes |
public void onGpsStatusChanged(int event) { if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) { try { // Check number of satellites in list to determine fix state GpsStatus status = myLocationManager.getGpsStatus(null); Iterable<GpsSatellite> satellites = status.getSatellites(); sat_count = 0; Iterator<GpsSatellite> satI = satellites.iterator(); while (satI.hasNext()) { GpsSatellite satellite = satI.next(); Log.d(LogUtils.generateTag(this), "Satellite: snr=" + satellite.getSnr() + ", elevation=" + satellite.getElevation()); sat_count++; } } catch (Exception e) { e.printStackTrace(); sat_count = min_gps_sat_count + 1; } Log.d(LogUtils.generateTag(this), "#### sat_count = " + sat_count); } }
Example #9
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 #10
Source File: DiagnosticsActivity.java From osmdroid with Apache License 2.0 | 6 votes |
@Override public void onGpsStatusChanged(int event) { switch (event) { case GpsStatus.GPS_EVENT_SATELLITE_STATUS: try { gpsStatus = lm.getGpsStatus(gpsStatus); } catch (SecurityException e) { e.printStackTrace(); } break; case GpsStatus.GPS_EVENT_FIRST_FIX: // Do something. break; } }
Example #11
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 #12
Source File: PasvLocListenerService.java From satstat with GNU General Public License v3.0 | 6 votes |
@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(); } }
Example #13
Source File: MainActivity.java From satstat with GNU General Public License v3.0 | 6 votes |
/** * 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); } }
Example #14
Source File: MainActivity.java From SpeedMeter with GNU General Public License v2.0 | 5 votes |
@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.class)); 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; } }
Example #15
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 #16
Source File: GpsSectionFragment.java From satstat with GNU General Public License v3.0 | 5 votes |
/** * Called by {@link MainActivity} when the status of the GPS changes. Updates GPS display. */ public void onGpsStatusChanged(GpsStatus status, int satsInView, int satsUsed, Iterable<GpsSatellite> sats) { gpsSats.setText(String.valueOf(satsUsed) + "/" + String.valueOf(satsInView)); gpsTtff.setText(String.valueOf(status.getTimeToFirstFix() / 1000)); gpsStatusView.showSats(sats); gpsSnrView.showSats(sats); }
Example #17
Source File: MapSectionFragment.java From satstat with GNU General Public License v3.0 | 5 votes |
/** * Called by {@link MainActivity} when the status of the GPS changes. Updates GPS display. */ public void onGpsStatusChanged(GpsStatus status, int satsInView, int satsUsed, Iterable<GpsSatellite> sats) { if (satsUsed == 0) { Location location = providerLocations.get(LocationManager.GPS_PROVIDER); if (location != null) markLocationAsStale(location); applyLocationProviderStyle(this.getContext(), LocationManager.GPS_PROVIDER, Const.LOCATION_PROVIDER_GRAY); } }
Example #18
Source File: GPSApplication.java From GPSLogger with GNU General Public License v3.0 | 5 votes |
@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(); break; } }
Example #19
Source File: GPSApplication.java From GPSLogger with GNU General Public License v3.0 | 5 votes |
public void updateSats() { try { if ((mlocManager != null) && (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)) { GpsStatus gs = mlocManager.getGpsStatus(null); int sats_inview = 0; // Satellites in view; int sats_used = 0; // Satellites used in fix; if (gs != null) { Iterable<GpsSatellite> sats = gs.getSatellites(); for (GpsSatellite sat : sats) { sats_inview++; if (sat.usedInFix()) sats_used++; //Log.w("myApp", "[#] GPSApplication.java - updateSats: i=" + i); } _NumberOfSatellites = sats_inview; _NumberOfSatellitesUsedInFix = sats_used; } else { _NumberOfSatellites = NOT_AVAILABLE; _NumberOfSatellitesUsedInFix = NOT_AVAILABLE; } } else { _NumberOfSatellites = NOT_AVAILABLE; _NumberOfSatellitesUsedInFix = NOT_AVAILABLE; } } catch (NullPointerException e) { _NumberOfSatellites = NOT_AVAILABLE; _NumberOfSatellitesUsedInFix = NOT_AVAILABLE; //Log.w("myApp", "[#] GPSApplication.java - updateSats: Caught NullPointerException: " + e); } //Log.w("myApp", "[#] GPSApplication.java - updateSats: Total=" + _NumberOfSatellites + " Used=" + _NumberOfSatellitesUsedInFix); }
Example #20
Source File: GPSServiceCommandTest.java From JayPS-AndroidApp with MIT License | 5 votes |
@SmallTest public void testRegistersNmeaListenerOnStart() throws Exception { when(_mockLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)).thenReturn(true); _serviceCommand.execute(_app); _serviceCommand.onGPSChangeState(new GPSChangeState(GPSChangeState.State.START)); verify(_mockLocationManager, timeout(2000).times(1)).addNmeaListener(any(GpsStatus.NmeaListener.class)); }
Example #21
Source File: GPSServiceCommandTest.java From JayPS-AndroidApp with MIT License | 5 votes |
@SmallTest public void testRemovesNmeaListenerOnStop() throws Exception { when(_mockLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)).thenReturn(true); _serviceCommand.execute(_app); _serviceCommand.onGPSChangeState(new GPSChangeState(GPSChangeState.State.START)); _serviceCommand.onGPSChangeState(new GPSChangeState(GPSChangeState.State.STOP)); verify(_mockLocationManager, timeout(2000).times(1)).removeNmeaListener(any(GpsStatus.NmeaListener.class)); }
Example #22
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 #23
Source File: LocationManagerProxy.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
public boolean addGpsStatusListener(android.location.GpsStatus.Listener listener) { boolean flag; if (a == null) { break MISSING_BLOCK_LABEL_23; } flag = a.addGpsStatusListener(listener); return flag; Throwable throwable; throwable; throwable.printStackTrace(); return false; }
Example #24
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 #25
Source File: LocationState.java From WhereYouGo with GNU General Public License v3.0 | 5 votes |
private static void postGpsSatelliteChange(final ArrayList<SatellitePosition> pos) { if (PreferenceValues.getCurrentActivity() == null) return; PreferenceValues.getCurrentActivity().runOnUiThread(new Runnable() { public void run() { for (int i = 0; i < mListeners.size(); i++) { mListeners.get(i).onGpsStatusChanged(GpsStatus.GPS_EVENT_SATELLITE_STATUS, pos); } } }); }
Example #26
Source File: ActivityLocation.java From RxTools-master with Apache License 2.0 | 5 votes |
private void getLocation() { if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(mContext, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 1); return; } locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 0, this); locationManager.addGpsStatusListener(new GpsStatus.Listener() { @Override public void onGpsStatusChanged(int event) { switch (event) { case GpsStatus.GPS_EVENT_STARTED: System.out.println("GPS_EVENT_STARTED"); mGpsCount.setText("0"); break; case GpsStatus.GPS_EVENT_FIRST_FIX: System.out.println("GPS_EVENT_FIRST_FIX"); break; case GpsStatus.GPS_EVENT_SATELLITE_STATUS: System.out.println("GPS_EVENT_SATELLITE_STATUS"); if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { return; } GpsStatus gpsStatus = locationManager.getGpsStatus(null); Iterable<GpsSatellite> gpsSatellites = gpsStatus.getSatellites(); int count = 0; Iterator iterator = gpsSatellites.iterator(); while (iterator.hasNext()) { count++; iterator.next(); } mGpsCount.setText(count + ""); break; case GpsStatus.GPS_EVENT_STOPPED: System.out.println("GPS_EVENT_STOPPED"); //gpsState.setText("已停止定位"); break; } } }); }
Example #27
Source File: e.java From letv with Apache License 2.0 | 5 votes |
private void b() { this.m = 0; this.l = 0; GpsStatus gpsStatus = b.getGpsStatus(null); if (gpsStatus != null) { int maxSatellites = gpsStatus.getMaxSatellites(); Iterator it = gpsStatus.getSatellites().iterator(); if (it != null) { while (it.hasNext() && this.l <= maxSatellites) { this.l++; if (((GpsSatellite) it.next()).usedInFix()) { this.m++; } } } } }
Example #28
Source File: JSONHelper.java From cordova-plugin-advanced-geolocation with Apache License 2.0 | 5 votes |
/** * 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(); }
Example #29
Source File: GpsStatusService.java From BackPackTrackII with GNU General Public License v3.0 | 5 votes |
@Override public void onGpsStatusChanged(int event) { if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) { // Count fixed/visible satellites int fixed = 0; int visible = 0; LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE); for (GpsSatellite sat : lm.getGpsStatus(null).getSatellites()) { visible++; if (sat.usedInFix()) fixed++; } // Persist fixed/visible satellites Log.i(TAG, "Satellites fixed/visible=" + fixed + "/" + visible); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(GpsStatusService.this); SharedPreferences.Editor editor = prefs.edit(); editor.putInt(SettingsFragment.PREF_SATS_FIXED, fixed); editor.putInt(SettingsFragment.PREF_SATS_VISIBLE, visible); editor.apply(); // Send state changed intent Intent intent = new Intent(GpsStatusService.this, BackgroundService.class); intent.setAction(BackgroundService.ACTION_STATE_CHANGED); startService(intent); } }
Example #30
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; } }