Java Code Examples for android.location.GpsStatus#getSatellites()
The following examples show how to use
android.location.GpsStatus#getSatellites() .
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: 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 2
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 3
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 4
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 5
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 6
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 7
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 8
Source File: SatelliteDataCollector.java From DataLogger with MIT License | 4 votes |
private Iterable<GpsSatellite> getGpsSatellites(){ synchronized (this) { GpsStatus status = mLocationManager.getGpsStatus(null); return (status == null) ? null : status.getSatellites(); } }