Location hasSpeed - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Location hasSpeed method.

This code example shows how to use the following methods:getSpeed, hasSpeed
		_dateTime = new Date(location.getTime()); 
	} 
 
	public void CalculateSpeed(LocationIdentifier previousLocation)
	{ 
		if(_location.hasSpeed())
			_speed = _location.getSpeed();
		else 
		{ 
			double diff = (double)(getDateTime().getTime() - previousLocation.getDateTime().getTime());
			double distance = _location.distanceTo(previousLocation.getLocation());
			_speed = (float) (distance/diff * 3600.0) ;
		} 
		 
	} 
	 
	public double getLongitudeDegrees() 
	{ 
		return _location.getLongitude();
	} 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:hasSpeed
    public float getBearing() { 
        return mLocation.getBearing();
    } 
 
    public boolean hasSpeed() { 
        return mLocation.hasSpeed();
    } 
 
    public void setSpeed(float speed) {
        mLocation.setSpeed(speed);
    } 
 
    public float getSpeed() { 
        return mLocation.getSpeed();
    } 
 
    public Bundle getExtras() {
        return mLocation.getExtras();
    } 
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getSpeed, hasSpeed
	 
	 
	@Override 
	public void onLocationChanged(Location location) {
    	if(location!=null) { 
            if(location.hasSpeed() && mySpeed != null){ 
            	mySpeed.addSpeedValue (location.getSpeed());
            	mySpeed.setStatus(true);
            } 
        }	 
	} 
 
	@Override 
	public void onProviderDisabled(String provider) {
		// TODO Auto-generated method stub 
		 
	} 
 
	@Override 
	public void onProviderEnabled(String provider) {
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:hasAccuracy, hasAltitude, hasBearing, hasSpeed
    public void logWithoutUpdate() { 
        makeEntry(); 
    } 
 
    public void logAdvancedFeatureStatus(Location location) {
        Log.i(_tag, "Accuracy  : " + location.hasAccuracy());
        Log.i(_tag, "Altitude  : " + location.hasAltitude());
        Log.i(_tag, "Bearing   : " + location.hasBearing());
        Log.i(_tag, "Speed     : " + location.hasSpeed());
 
    } 
 
    protected void makeEntry() { 
        Log.i(_tag, "Provider  : " + _location.getProvider());
        Log.i(_tag, "Latitude  : " + _location.getLatitude());
        Log.i(_tag, "Longitude : " + _location.getLongitude());
        Log.i(_tag, "Accuracy  : " + _location.getAccuracy());
        Log.i(_tag, "Altitude  : " + _location.getAltitude());
        Log.i(_tag, "Bearing   : " + _location.getBearing());
        Log.i(_tag, "Speed     : " + _location.getSpeed());
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getSpeed, hasSpeed
    	} 
    	return addressString;
	} 
	 
	private double getSpeed(Location location) {
		if (location != null && location.hasSpeed()) {
			return (double) location.getSpeed();		// meters per second
		} else { 
			return -1.0; 
		} 
	} 
	 
	private String getSpeedString(Location location) {
		if (location != null && location.hasSpeed()) {
			float speed_ms = location.getSpeed();
			double speed_kmh = ((3600.0/1000.0) * speed_ms);
			return "Speed: " + df.format(speed_kmh).replaceAll(",", ".") + " km/h";
		} else { 
			return "Speed not available"; 
		} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAltitude, getBearing, getLatitude, getLongitude, getProvider
    { 
 
        StringBuilder waypoint = new StringBuilder();
 
        waypoint.append("\n<wpt lat=\"")
                .append(String.valueOf(loc.getLatitude()))
                .append("\" lon=\"")
                .append(String.valueOf(loc.getLongitude()))
                .append("\">");
 
        if (loc.hasAltitude())
        { 
            waypoint.append("<ele>").append(String.valueOf(loc.getAltitude())).append("</ele>");
        } 
 
        if (loc.hasBearing())
        { 
            waypoint.append("<course>").append(String.valueOf(loc.getBearing())).append("</course>");
        } 
 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAccuracy, getAltitude, getBearing, getExtras, getLatitude
                                  boolean hasSpeed, double speed,
                                  boolean hasAccuracy, double accuracy,
                                  boolean hasAcceleration, double acceleration);
 
  private void sendLocation(Location location) {
    Bundle extras = location.getExtras();
 
    setLocation(location.getTime(),
                extras != null ? extras.getInt("satellites", -1) : -1,
                location.getLongitude(), location.getLatitude(),
                location.hasAltitude(), location.getAltitude(),
                location.hasBearing(), location.getBearing(),
                location.hasSpeed(), location.getSpeed(),
                location.hasAccuracy(), location.getAccuracy(),
                true, acceleration);
  } 
 
  private void setConnectedSafe(int connected) {
    if (!safeDestruct.Increment())
      return; 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAccuracy, getBearing, getLatitude, getLongitude, getSpeed
  /** 
   * Writes a location line of the given type to the log file, unpacking the 
   * location object into E7 lat, lng, and accuracy. 
   */ 
  private void writeLocationLine(long absoluteTimeNanos, String key, Location loc) {
    long latE7 = (long) (loc.getLatitude() * 1e7);
    long lngE7 = (long) (loc.getLongitude() * 1e7);
    float accuracy = loc.getAccuracy();
    float bearing = loc.hasBearing() ? loc.getBearing() : -1.0f;
    float speed = loc.hasSpeed() ? loc.getSpeed() : -1.0f;
 
    writeLine(absoluteTimeNanos, key, "" + latE7 + " " + lngE7 + " " + accuracy + " " + bearing
        + " " + speed);
  } 
 
  /** 
   * Writes a line to the log file. 
   */ 
  private synchronized void writeLine(long absoluteTimeNanos, String sensor, String value) {
    writeTimestamp(absoluteTimeNanos);
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAccuracy, getAltitude, getBearing, getLatitude, getLongitude
        time = System.currentTimeMillis();
    } 
 
    @Implementation 
    public void set(Location l) {
        time = l.getTime();
        provider = l.getProvider();
        latitude = l.getLatitude();
        longitude = l.getLongitude();
        accuracy = l.getAccuracy();
        bearing = l.getBearing();
        altitude = l.getAltitude();
        speed = l.getSpeed();
 
        hasAccuracy = l.hasAccuracy();
        hasAltitude = l.hasAltitude();
        hasBearing = l.hasBearing();
        hasSpeed = l.hasSpeed();
    } 
 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAccuracy, getAltitude, getBearing, getExtras, getLatitude
                                  boolean hasSpeed, double speed,
                                  boolean hasAccuracy, double accuracy,
                                  boolean hasAcceleration, double acceleration);
 
  private void sendLocation(Location location) {
    Bundle extras = location.getExtras();
 
    setLocation(location.getTime(),
                extras != null ? extras.getInt("satellites", -1) : -1,
                location.getLongitude(), location.getLatitude(),
                location.hasAltitude(), location.getAltitude(),
                location.hasBearing(), location.getBearing(),
                location.hasSpeed(), location.getSpeed(),
                location.hasAccuracy(), location.getAccuracy(),
                true, acceleration);
  } 
 
  private void setConnectedSafe(int connected) {
    if (!safeDestruct.Increment())
      return; 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Location hasSpeed Questions & Answers:

hasSpeed Method Overview
True if this location has a speed.
See Code Examples for other Android Location Methods: