List of usage examples for android.location LocationManager GPS_PROVIDER
String GPS_PROVIDER
To view the source code for android.location LocationManager GPS_PROVIDER.
Click Source Link
From source file:com.androzic.location.LocationService.java
@Override public void onStatusChanged(String provider, int status, Bundle extras) { if (LocationManager.GPS_PROVIDER.equals(provider)) { switch (status) { case LocationProvider.TEMPORARILY_UNAVAILABLE: case LocationProvider.OUT_OF_SERVICE: tearTrack();/*w w w. ja va 2 s . c o m*/ updateNotification(); break; } } }
From source file:com.dragon4.owo.ar_trace.ARCore.MixView.java
public void onLocationChanged(Location location) { try {/*from w w w . java 2 s.c o m*/ killOnError(); // ? ? gpsLat = location.getLatitude(); gpsLong = location.getLongitude(); // ? ? ?. ? ? ? Log.v(TAG, "Location Changed: " + location.getProvider() + " lat: " + location.getLatitude() + " lon: " + location.getLongitude() + " alt: " + location.getAltitude() + " acc: " + location.getAccuracy()); // ? ?? if (LocationManager.GPS_PROVIDER.equals(location.getProvider())) { // ? ? synchronized (mixContext.curLoc) { mixContext.curLoc = location; } // ?? if (!dataView.isFrozen()) // ??? ?? ? dataView.getDataHandler().onLocationChanged(location); /* ?? 3km ?? * * ??, ?? */ // ? Location lastLoc = mixContext.getLocationAtLastDownload(); if (lastLoc == null) // ?? mixContext.setLocationAtLastDownload(location); // ? else { // float threshold = dataView.getRadius() * 1000f / 3f; Log.v(TAG, "Location Change: " + " threshold " + threshold + " distanceto " + location.distanceTo(lastLoc)); // ?? if (location.distanceTo(lastLoc) > threshold) { Log.d(TAG, "Restarting download due to location change"); dataView.doStart(); } } isGpsEnabled = true; // GPS ? } } catch (Exception ex) { ex.printStackTrace(); } }
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;/*from w w w .j a v a 2 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; } }
From source file:es.upv.riromu.arbre.main.MainActivity.java
private Boolean displayGpsStatus() { ContentResolver contentResolver = getBaseContext().getContentResolver(); boolean gpsStatus = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); return gpsStatus; }
From source file:com.google.android.apps.mytracks.services.TrackRecordingService.java
/** * Called when location changed./*from w ww .j a v a2 s . co m*/ * * @param location the location */ private void onLocationChangedAsync(Location location) { try { if (!isRecording() || isPaused()) { Log.w(TAG, "Ignore onLocationChangedAsync. Not recording or paused."); return; } Track track = myTracksProviderUtils.getTrack(recordingTrackId); if (track == null) { Log.w(TAG, "Ignore onLocationChangedAsync. No track."); return; } if (!LocationUtils.isValidLocation(location)) { Log.w(TAG, "Ignore onLocationChangedAsync. location is invalid."); return; } if (location.getAccuracy() > minRequiredAccuracy) { Log.d(TAG, "Ignore onLocationChangedAsync. Poor accuracy."); return; } Location lastValidTrackPoint = getLastValidTrackPointInCurrentSegment(track.getId()); long idleTime = lastValidTrackPoint != null ? location.getTime() - lastValidTrackPoint.getTime() : 0L; locationListenerPolicy.updateIdleTime(idleTime); if (currentRecordingInterval != locationListenerPolicy.getDesiredPollingInterval()) { registerLocationListener(); } SensorDataSet sensorDataSet = getSensorDataSet(); if (sensorDataSet != null) { location = new MyTracksLocation(location, sensorDataSet, gsmSignal); } // Always insert the first segment location if (!currentSegmentHasLocation) { insertLocation(track, location, null); currentSegmentHasLocation = true; lastLocation = location; return; } if (!LocationUtils.isValidLocation(lastValidTrackPoint)) { /* * Should not happen. The current segment should have a location. Just * insert the current location. */ insertLocation(track, location, null); lastLocation = location; return; } double distanceToLastTrackLocation = location.distanceTo(lastValidTrackPoint); if (distanceToLastTrackLocation < minRecordingDistance && sensorDataSet == null) { Log.d(TAG, "Not recording location due to min recording distance."); } else if (distanceToLastTrackLocation > maxRecordingDistance) { insertLocation(track, lastLocation, lastValidTrackPoint); Location pause = new Location(LocationManager.GPS_PROVIDER); pause.setLongitude(0); pause.setLatitude(PAUSE_LATITUDE); pause.setTime(lastLocation.getTime()); insertLocation(track, pause, null); insertLocation(track, location, null); } else { /* * (distanceToLastTrackLocation >= minRecordingDistance || * hasSensorData) && distanceToLastTrackLocation <= maxRecordingDistance */ insertLocation(track, lastLocation, lastValidTrackPoint); insertLocation(track, location, null); } lastLocation = location; } catch (Error e) { Log.e(TAG, "Error in onLocationChangedAsync", e); throw e; } catch (RuntimeException e) { Log.e(TAG, "RuntimeException in onLocationChangedAsync", e); throw e; } }
From source file:com.snt.bt.recon.activities.MainActivity.java
public boolean gpsStatusCheck() { final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { buildAlertMessageNoGps();//from www .j a va 2 s.com return false; } else return true; }
From source file:com.crearo.gpslogger.GpsLoggingService.java
private boolean isFromValidListener(Location loc) { if (!preferenceHelper.getChosenListeners().contains(LocationManager.GPS_PROVIDER) && !preferenceHelper.getChosenListeners().contains(LocationManager.NETWORK_PROVIDER)) { return true; }// w w w . j av a 2 s .co m if (!preferenceHelper.getChosenListeners().contains(LocationManager.NETWORK_PROVIDER)) { return loc.getProvider().equalsIgnoreCase(LocationManager.GPS_PROVIDER); } if (!preferenceHelper.getChosenListeners().contains(LocationManager.GPS_PROVIDER)) { return !loc.getProvider().equalsIgnoreCase(LocationManager.GPS_PROVIDER); } return true; }
From source file:com.woofy.haifa.MapActivity.java
public static float latLngDistance(LatLng ll1, LatLng ll2) { Location loc1 = new Location(LocationManager.GPS_PROVIDER); Location loc2 = new Location(LocationManager.GPS_PROVIDER); loc1.setLatitude(ll1.latitude);/*from w ww . j a v a 2s . com*/ loc1.setLongitude(ll1.longitude); loc2.setLatitude(ll2.latitude); loc2.setLongitude(ll2.longitude); return loc1.distanceTo(loc2); }
From source file:br.com.bioscada.apps.biotracks.services.TrackRecordingService.java
/** * Pauses the current track.//from w w w . ja v a2 s.c o m */ private void pauseCurrentTrack() { if (!isRecording() || isPaused()) { Log.d(TAG, "Ignore pauseCurrentTrack. Not recording or paused."); return; } // Update shared preferences recordingTrackPaused = true; PreferencesUtils.setBoolean(this, R.string.recording_track_paused_key, true); // Update database Track track = myTracksProviderUtils.getTrack(recordingTrackId); if (track != null) { insertLocation(track, lastLocation, getLastValidTrackPointInCurrentSegment(track.getId())); Location pause = new Location(LocationManager.GPS_PROVIDER); pause.setLongitude(0); pause.setLatitude(PAUSE_LATITUDE); pause.setTime(System.currentTimeMillis()); insertLocation(track, pause, null); } endRecording(false, recordingTrackId); }
From source file:com.barkside.travellocblog.LocationUpdates.java
/** * Check if user has turned on location services. If not, then we'll never get * onConnected or onLocationChanged events. * Google Play services does not catch this condition, so have to manually check it. http://stackoverflow.com/questions/16862987/android-check-location-services-enabled-with-play-services-location-api *//*from ww w .j a v a2 s. c o m*/ public boolean isLocationServiceOn() { LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // Was checking for non-empty list locationManager.getProviders(true) but // that also contains the PASSIVE provider, which may not return // any location in some cases. // For best performance, need both GPS and NETWORK, but for this call, // will accept either one being on. return (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER) || locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)); }