Android 12 Developer Preview is here! Try it out, and give us your feedback!

CarLocation

public final class CarLocation
extends Object

java.lang.Object
   ↳ androidx.car.app.model.CarLocation


Represents a geographical location with a latitude and a longitude.

Summary

Public methods

static CarLocation create(double latitude, double longitude)

Returns a new instance of a CarLocation.

static CarLocation create(Location location)

Returns a new instance of a CarLocation with the same latitude and longitude contained in the given Location.

boolean equals(Object other)
double getLatitude()

Returns the latitude of the location, in degrees.

double getLongitude()

Returns the longitude of the location, in degrees.

int hashCode()
String toString()

Inherited methods

Public methods

create

public static CarLocation create (double latitude, 
                double longitude)

Returns a new instance of a CarLocation.

Parameters
latitude double

longitude double

Returns
CarLocation

create

public static CarLocation create (Location location)

Returns a new instance of a CarLocation with the same latitude and longitude contained in the given Location.

Parameters
location Location

Returns
CarLocation

Throws
NullPointerException if location is null

equals

public boolean equals (Object other)

Parameters
other Object

Returns
boolean

getLatitude

public double getLatitude ()

Returns the latitude of the location, in degrees.

Returns
double

getLongitude

public double getLongitude ()

Returns the longitude of the location, in degrees.

Returns
double

hashCode

public int hashCode ()

Returns
int

toString

public String toString ()

Returns
String