Location hasBearing - 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 hasBearing method.

This code example shows how to use the following methods:hasBearing
    public double getAltitude() { 
        return mLocation.getAltitude();
    } 
 
    public boolean hasBearing() { 
        return mLocation.hasBearing();
    } 
 
    public void setBearing(float bearing) {
        mLocation.setBearing(bearing);
    } 
 
    public float getBearing() { 
        return mLocation.getBearing();
    } 
 
    public boolean hasSpeed() { 
        return mLocation.hasSpeed();
    } 
 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getBearing, hasBearing
			return "Speed not available"; 
		} 
	} 
	 
	private double getBearing(Location location) {
		if (location != null && location.hasBearing()) {
			return (double) location.getBearing();
		} else { 
			return -1.0; 
		} 
	} 
	 
	private String getBearingString(Location location) {
		if (location != null && location.hasBearing()) {
			float degrees = location.getBearing();
			return "Bearing: " + degrees + "�";
		} else { 
			return "Bearing not available"; 
		} 
	} 
7
CodeRank
Experience pair programming with AI  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
Experience pair programming with AI  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
Experience pair programming with AI  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
Experience pair programming with AI  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
Experience pair programming with AI  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
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAltitude, getBearing, getSpeed, hasAltitude, hasBearing
	 
	//Set Extra Info for Screen 
	protected void SetExtras(Location mlocation)
	{ 
		 
		if (mlocation.hasSpeed())
			speed= mlocation.getSpeed()*2.23693629;
		 
		if (mlocation.hasAltitude())
			elevation=mlocation.getAltitude()*3.2808399;
		 
		if (mlocation.hasBearing())
		{ 
		 
			bearing = mlocation.getBearing();
		} 
		 
	} 
 
	 
6
CodeRank
Experience pair programming with AI  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
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAccuracy, getAltitude, getBearing, getLatitude, getLongitude
 
    public JSONObject returnLocationJSON(Location loc) {
        JSONObject o = new JSONObject();
 
        try { 
            o.put("latitude", loc.getLatitude());
            o.put("longitude", loc.getLongitude());
            o.put("altitude", (loc.hasAltitude() ? loc.getAltitude() : null));
            o.put("accuracy", loc.getAccuracy());
            o.put("heading", (loc.hasBearing() ? (loc.hasSpeed() ? loc.getBearing() : null) : null));
            o.put("velocity", loc.getSpeed());
            o.put("timestamp", loc.getTime());
        } catch (JSONException e) {
            // TODO Auto-generated catch block 
            e.printStackTrace();
        } 
 
        return o;
    } 
 
6
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Location hasBearing Questions & Answers:

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