当前位置: 首页>>代码示例>>Java>>正文


Java GpsStatus.getSatellites方法代码示例

本文整理汇总了Java中android.location.GpsStatus.getSatellites方法的典型用法代码示例。如果您正苦于以下问题:Java GpsStatus.getSatellites方法的具体用法?Java GpsStatus.getSatellites怎么用?Java GpsStatus.getSatellites使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.location.GpsStatus的用法示例。


在下文中一共展示了GpsStatus.getSatellites方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onGpsStatusChanged

import android.location.GpsStatus; //导入方法依赖的package包/类
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);

            }
        }
 
开发者ID:richardradics,项目名称:MVPAndroidBootstrap,代码行数:26,代码来源:LocationHelper.java

示例2: updateSats

import android.location.GpsStatus; //导入方法依赖的package包/类
public void updateSats() {
    if ((mlocManager != null) && (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED))
    {
        final 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;
    }
    //Log.w("myApp", "[#] GPSApplication.java - updateSats: Total=" + _NumberOfSatellites + " Used=" + _NumberOfSatellitesUsedInFix);
}
 
开发者ID:BasicAirData,项目名称:GPSLogger,代码行数:27,代码来源:GPSApplication.java

示例3: onGpsStatusChanged

import android.location.GpsStatus; //导入方法依赖的package包/类
@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();
	}
}
 
开发者ID:mvglasow,项目名称:satstat,代码行数:17,代码来源:PasvLocListenerService.java

示例4: onGpsStatusChanged

import android.location.GpsStatus; //导入方法依赖的package包/类
/**
   * 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);
}
  }
 
开发者ID:mvglasow,项目名称:satstat,代码行数:24,代码来源:MainActivity.java

示例5: satelliteDataJSON

import android.location.GpsStatus; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:43,代码来源:JSONHelper.java

示例6: onGpsStatusChanged

import android.location.GpsStatus; //导入方法依赖的package包/类
@Override
public void onGpsStatusChanged(final int event) {
	int satCount = -1;

	switch (event) {
		case GpsStatus.GPS_EVENT_FIRST_FIX:
			satCount = 0;
			break;
		case GpsStatus.GPS_EVENT_STARTED:
			satCount = -1;
			break;
		case GpsStatus.GPS_EVENT_STOPPED:
			satCount = -1;
			break;
		case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
			// first of all we check if the time from the last used fix to the current fix is greater than the logging interval
			if ((event != GpsStatus.GPS_EVENT_SATELLITE_STATUS)
					|| (mLastGPSTimestamp + gpsLoggingInterval) < System.currentTimeMillis()) {
				mLastGPSTimestamp = System.currentTimeMillis(); // save the time of this fix

				final GpsStatus status = lmgr.getGpsStatus(null);

				// Count active satellites
				satCount = 0;
				for (@SuppressWarnings("unused") final GpsSatellite sat:status.getSatellites()) {
					satCount++;
				}
			}
			break;
		default:
			break;
	}

	if (mListener != null) {
		mListener.onSatInfo(satCount);
	}

}
 
开发者ID:saintbyte,项目名称:openbmap,代码行数:39,代码来源:GpsProvider.java

示例7: showGpsStatusInfo

import android.location.GpsStatus; //导入方法依赖的package包/类
private void showGpsStatusInfo(GpsStatus gpsStatus) {
    max_satellites.setText(String.valueOf(gpsStatus.getMaxSatellites()));
    int satelliteCount = 0;
    for (GpsSatellite gpsSatellite : gpsStatus.getSatellites()) {
        // TODO: Show each GpsSatellite detail.
        satelliteCount++;
    }
    satellites.setText(String.valueOf(satelliteCount));
    first_fix_time.setText(String.valueOf(gpsStatus.getTimeToFirstFix()));
}
 
开发者ID:samuel22gj,项目名称:OtterBenchmark,代码行数:11,代码来源:GpsMonitor.java

示例8: toBundle

import android.location.GpsStatus; //导入方法依赖的package包/类
private Bundle toBundle(Bundle ret, GpsStatus gpsStatus) {
	int count_seen = 0;
	int count_fix = 0;
	for (GpsSatellite s: gpsStatus.getSatellites()) {
		count_seen++;
		if (s.usedInFix()) {
			count_fix++;
		}
	}
	ret.putInt("satellites", count_fix);
	ret.putInt("satellites_seen", count_seen);
	return ret;
}
 
开发者ID:emdete,项目名称:tabulae,代码行数:14,代码来源:LocusService.java

示例9: onGpsStatusChanged

import android.location.GpsStatus; //导入方法依赖的package包/类
@Override
public void onGpsStatusChanged(int event) {
    if (GpsStatus.GPS_EVENT_STARTED == event) {
        Log.i(TAG, "GPS started");
    } else if (GpsStatus.GPS_EVENT_STOPPED == event) {
        Log.i(TAG, "GPS stopped");
    } else if (GpsStatus.GPS_EVENT_FIRST_FIX == event) {
        Log.i(TAG, "GPS first fix");
    } else if (GpsStatus.GPS_EVENT_SATELLITE_STATUS == event) {
        if (locationManager != null) {
            final GpsStatus s = locationManager.getGpsStatus(null);
            context.satellitesInUse = 0;
            context.satellitesInView = 0;
            for (final GpsSatellite sat : s.getSatellites()) {
                if (sat.usedInFix()) {
                    context.satellitesInUse += 1;
                }
                context.satellitesInView += 1;
            }
            if (BuildConfig.DEBUG) {
                Log.v(TAG, "GPS satellite status: " + context.satellitesInUse
                        + " satellite(s) used in fix");
            }
            fireNmeaRelayContextChanged();
        }
    }
}
 
开发者ID:alexandreroman,项目名称:nrelay,代码行数:28,代码来源:NmeaRelayService.java

示例10: onGpsStatusChanged

import android.location.GpsStatus; //导入方法依赖的package包/类
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;
    }
}
 
开发者ID:flyingrub,项目名称:SpeedMeter,代码行数:37,代码来源:MainActivity.java

示例11: countSatellites

import android.location.GpsStatus; //导入方法依赖的package包/类
/**
 * Counts number of satellites used in last fix.
 * @return The number of satellites
 */
private int countSatellites() {
	int count = 0;
	GpsStatus status = lmgr.getGpsStatus(null);
	for(GpsSatellite sat:status.getSatellites()) {
		if (sat.usedInFix()) {
			count++;
		}
	}
	
	return count;
}
 
开发者ID:WanderWiki,项目名称:WanderWiki-client,代码行数:16,代码来源:GPSLogger.java

示例12: onGpsStatusChanged

import android.location.GpsStatus; //导入方法依赖的package包/类
@Override
public void onGpsStatusChanged(int event) {
	switch (event) {
	case GpsStatus.GPS_EVENT_STARTED:
		setTitle(R.string.statusStartedGPS);
		break;
	case GpsStatus.GPS_EVENT_STOPPED:
		setTitle(R.string.statusStoppedGPS);
		break;
	case GpsStatus.GPS_EVENT_FIRST_FIX:
		setTitle(R.string.statusFixGPS);
		break;
	case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
		GpsStatus gpsStatus = locationManager.getGpsStatus(null);

		int usedSats = 0;
		for (GpsSatellite sat : gpsStatus.getSatellites()) {
			if (sat.usedInFix()) {
				usedSats++;
			}
		}

		String gpsText = "";
		if (usedSats == 0) {
			gpsText = "brak (0)";
		} else if (usedSats >= 1 && usedSats <= 3) {
			gpsText = "s�aby (1-3)";
		} else if (usedSats >= 4 && usedSats <= 6) {
			gpsText = "dobry (4-6)";
		} else if (usedSats >= 7) {
			gpsText = "znakomity (7+)";
		}

		setTitle(getString(R.string.app_name) + ". GPS: " + gpsText);
		break;
	}
}
 
开发者ID:ABAKUS-ST,项目名称:StrazakOSM,代码行数:38,代码来源:MainActivity.java

示例13: onGpsStatusChanged

import android.location.GpsStatus; //导入方法依赖的package包/类
public void onGpsStatusChanged(int event)
{
        switch( event )
        {
                case GpsStatus.GPS_EVENT_STARTED:
                        // Started...
              	  	startListen();
              	  	latLongptr.updateLatitudeLongitude();
              	  	if (Constants.DEBUG)
              	  		Log.v("debug","GPS starting...\n");
                        break ;
                case GpsStatus.GPS_EVENT_FIRST_FIX:
                        // First Fix...
              	  if (Constants.DEBUG)
              		  Log.v("debug","GPS first fix \n");
              	  latLongptr.updateLatitudeLongitude();
                        break ;
                case GpsStatus.GPS_EVENT_STOPPED:
                        // Stopped...
              	  stopListen();
              	  location = null;
              	  latLongptr.updateLatitudeLongitude();
              	  if (Constants.DEBUG)
              		  Log.v("debug","GPS stopped.\n");
                        break ;
                case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
                    GpsStatus xGpsStatus = locationManager.getGpsStatus(null) ;
                    Iterable<GpsSatellite> iSatellites = xGpsStatus.getSatellites() ;
                    Iterator<GpsSatellite> it = iSatellites.iterator() ;
                    while ( it.hasNext() )
                    {
                            GpsSatellite oSat = (GpsSatellite) it.next() ;
                            if (Constants.DEBUG)
                          	  Log.v("debug","LocationActivity - onGpsStatusChange: Satellites: " +
            oSat.getSnr() ) ;
                    }
                    break ; 
        }
}
 
开发者ID:CalSPEED,项目名称:CalSPEED-Android,代码行数:40,代码来源:NdtLocation.java

示例14: onGpsStatusChanged

import android.location.GpsStatus; //导入方法依赖的package包/类
@Override
public void onGpsStatusChanged(int event) {
	// Update GPS Status image according to event
	ImageView imgSatIndicator = (ImageView) findViewById(R.id.gpsstatus_record_imgSatIndicator);

	switch (event) {
	case GpsStatus.GPS_EVENT_FIRST_FIX:
		imgSatIndicator.setImageResource(R.drawable.sat_indicator_0);
		activity.onGpsEnabled();
		break;
	case GpsStatus.GPS_EVENT_STARTED:
		imgSatIndicator.setImageResource(R.drawable.sat_indicator_unknown);
		break;
	case GpsStatus.GPS_EVENT_STOPPED:
		imgSatIndicator.setImageResource(R.drawable.sat_indicator_off);
		activity.onGpsDisabled();
		break;
	case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
		// first of all we check if the time from the last used fix to the current fix is greater than the logging interval
		if((event != GpsStatus.GPS_EVENT_SATELLITE_STATUS) || (lastGPSTimestampStatus + gpsLoggingInterval) < System.currentTimeMillis()){
			lastGPSTimestampStatus = System.currentTimeMillis(); // save the time of this fix

			GpsStatus status = lmgr.getGpsStatus(null);

			// Count active satellites
			int satCount = 0;
			for (@SuppressWarnings("unused") GpsSatellite sat:status.getSatellites()) {
				satCount++;
			}

			// Count how many bars should we draw
			int nbBars = 0;
			for (int i=0; i<SAT_INDICATOR_TRESHOLD.length; i++) {
				if (satCount >= SAT_INDICATOR_TRESHOLD[i]) {
					nbBars = i;
				}
			}
			Log.v(TAG, "Found " + satCount + " satellites. Will draw " + nbBars + " bars.");			
			imgSatIndicator.setImageResource(getResources().getIdentifier("drawable/sat_indicator_" + nbBars, null, OSMTracker.class.getPackage().getName()));
		}
		break;
	}
}
 
开发者ID:WanderWiki,项目名称:WanderWiki-client,代码行数:44,代码来源:GpsStatusRecord.java


注:本文中的android.location.GpsStatus.getSatellites方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。