Address  |  API reference  |  Android Developers


public class Address
extends Object implements Parcelable



A class representing an Address, that is, a set of Strings describing a location. The address format is a simplified version of xAL (eXtensible Address Language) http://www.oasis-open.org/committees/ciq/ciq.html#6

Summary

Inherited constants

From interface android.os.Parcelable

int CONTENTS_FILE_DESCRIPTOR

Descriptor bit used with describeContents(): indicates that the Parcelable object's flattened representation includes a file descriptor.

int PARCELABLE_WRITE_RETURN_VALUE

Flag for use with writeToParcel(Parcel, int): the object being written is a return value, that is the result of a function such as "Parcelable someFunction()", "void someFunction(out Parcelable)", or "void someFunction(inout Parcelable)".

Fields

public static final Creator<Address> CREATOR

Public constructors

Address(Locale locale)

Constructs a new Address object set to the given Locale and with all other fields initialized to null or false.

Public methods

void clearLatitude()

Removes any latitude associated with this address.

void clearLongitude()

Removes any longitude associated with this address.

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

String getAddressLine(int index)

Returns a line of the address numbered by the given index (starting at 0), or null if no such line is present.

String getAdminArea()

Returns the administrative area name of the address, for example, "CA", or null if it is unknown

String getCountryCode()

Returns the country code of the address, for example "US", or null if it is unknown.

String getCountryName()

Returns the localized country name of the address, for example "Iceland", or null if it is unknown.

Bundle getExtras()

Returns additional provider-specific information about the address as a Bundle.

String getFeatureName()

Returns the feature name of the address, for example, "Golden Gate Bridge", or null if it is unknown

double getLatitude()

Returns the latitude of the address if known.

Locale getLocale()

Returns the Locale associated with this address.

String getLocality()

Returns the locality of the address, for example "Mountain View", or null if it is unknown.

double getLongitude()

Returns the longitude of the address if known.

int getMaxAddressLineIndex()

Returns the largest index currently in use to specify an address line.

String getPhone()

Returns the phone number of the address if known, or null if it is unknown.

String getPostalCode()

Returns the postal code of the address, for example "94110", or null if it is unknown.

String getPremises()

Returns the premises of the address, or null if it is unknown.

String getSubAdminArea()

Returns the sub-administrative area name of the address, for example, "Santa Clara County", or null if it is unknown

String getSubLocality()

Returns the sub-locality of the address, or null if it is unknown.

String getSubThoroughfare()

Returns the sub-thoroughfare name of the address, which may be null.

String getThoroughfare()

Returns the thoroughfare name of the address, for example, "1600 Ampitheater Parkway", which may be null

String getUrl()

Returns the public URL for the address if known, or null if it is unknown.

boolean hasLatitude()

Returns true if a latitude has been assigned to this Address, false otherwise.

boolean hasLongitude()

Returns true if a longitude has been assigned to this Address, false otherwise.

void setAddressLine(int index, String line)

Sets the line of the address numbered by index (starting at 0) to the given String, which may be null.

void setAdminArea(String adminArea)

Sets the administrative area name of the address to the given String, which may be null

void setCountryCode(String countryCode)

Sets the country code of the address to the given String, which may be null.

void setCountryName(String countryName)

Sets the country name of the address to the given String, which may be null.

void setExtras(Bundle extras)

Sets the extra information associated with this fix to the given Bundle.

void setFeatureName(String featureName)

Sets the feature name of the address to the given String, which may be null

void setLatitude(double latitude)

Sets the latitude associated with this address.

void setLocality(String locality)

Sets the locality of the address to the given String, which may be null.

void setLongitude(double longitude)

Sets the longitude associated with this address.

void setPhone(String phone)

Sets the phone number associated with this address.

void setPostalCode(String postalCode)

Sets the postal code of the address to the given String, which may be null.

void setPremises(String premises)

Sets the premises of the address to the given String, which may be null.

void setSubAdminArea(String subAdminArea)

Sets the sub-administrative area name of the address to the given String, which may be null

void setSubLocality(String sublocality)

Sets the sub-locality of the address to the given String, which may be null.

void setSubThoroughfare(String subthoroughfare)

Sets the sub-thoroughfare name of the address, which may be null.

void setThoroughfare(String thoroughfare)

Sets the thoroughfare name of the address, which may be null.

void setUrl(String Url)

Sets the public URL associated with this address.

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel parcel, int flags)

Flatten this object in to a Parcel.

Inherited methods

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

From interface android.os.Parcelable

abstract int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

abstract void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Fields

Public constructors

Address

public Address (Locale locale)

Constructs a new Address object set to the given Locale and with all other fields initialized to null or false.

Parameters
locale Locale

Public methods

clearLatitude

public void clearLatitude ()

Removes any latitude associated with this address.

clearLongitude

public void clearLongitude ()

Removes any longitude associated with this address.

describeContents

public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(Parcel,int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
Value is either 0 or

getAddressLine

public String getAddressLine (int index)

Returns a line of the address numbered by the given index (starting at 0), or null if no such line is present.

Parameters
index int
Returns
String
Throws
IllegalArgumentException if index < 0

getAdminArea

public String getAdminArea ()

Returns the administrative area name of the address, for example, "CA", or null if it is unknown

Returns
String

getCountryCode

public String getCountryCode ()

Returns the country code of the address, for example "US", or null if it is unknown.

Returns
String

getCountryName

public String getCountryName ()

Returns the localized country name of the address, for example "Iceland", or null if it is unknown.

Returns
String
public Bundle getExtras ()

Returns additional provider-specific information about the address as a Bundle. The keys and values are determined by the provider. If no additional information is available, null is returned.

Returns
Bundle

getFeatureName

public String getFeatureName ()

Returns the feature name of the address, for example, "Golden Gate Bridge", or null if it is unknown

Returns
String

getLatitude

public double getLatitude ()

Returns the latitude of the address if known.

Returns
double
Throws
IllegalStateException if this Address has not been assigned a latitude.

getLocale

public Locale getLocale ()

Returns the Locale associated with this address.

Returns
Locale

getLocality

public String getLocality ()

Returns the locality of the address, for example "Mountain View", or null if it is unknown.

Returns
String

getLongitude

public double getLongitude ()

Returns the longitude of the address if known.

Returns
double
Throws
IllegalStateException if this Address has not been assigned a longitude.

getMaxAddressLineIndex

public int getMaxAddressLineIndex ()

Returns the largest index currently in use to specify an address line. If no address lines are specified, -1 is returned.

Returns
int

getPhone

public String getPhone ()

Returns the phone number of the address if known, or null if it is unknown.

Returns
String
Throws
IllegalStateException if this Address has not been assigned a phone number.

getPostalCode

public String getPostalCode ()

Returns the postal code of the address, for example "94110", or null if it is unknown.

Returns
String

getPremises

public String getPremises ()

Returns the premises of the address, or null if it is unknown.

Returns
String

getSubAdminArea

public String getSubAdminArea ()

Returns the sub-administrative area name of the address, for example, "Santa Clara County", or null if it is unknown

Returns
String

getSubLocality

public String getSubLocality ()

Returns the sub-locality of the address, or null if it is unknown. For example, this may correspond to the neighborhood of the locality.

Returns
String

getSubThoroughfare

public String getSubThoroughfare ()

Returns the sub-thoroughfare name of the address, which may be null. This may correspond to the street number of the address.

Returns
String

getThoroughfare

public String getThoroughfare ()

Returns the thoroughfare name of the address, for example, "1600 Ampitheater Parkway", which may be null

Returns
String

getUrl

public String getUrl ()

Returns the public URL for the address if known, or null if it is unknown.

Returns
String

hasLatitude

public boolean hasLatitude ()

Returns true if a latitude has been assigned to this Address, false otherwise.

Returns
boolean

hasLongitude

public boolean hasLongitude ()

Returns true if a longitude has been assigned to this Address, false otherwise.

Returns
boolean

setAddressLine

public void setAddressLine (int index, 
                String line)

Sets the line of the address numbered by index (starting at 0) to the given String, which may be null.

Parameters
index int
line String
Throws
IllegalArgumentException if index < 0

setAdminArea

public void setAdminArea (String adminArea)

Sets the administrative area name of the address to the given String, which may be null

Parameters
adminArea String

setCountryCode

public void setCountryCode (String countryCode)

Sets the country code of the address to the given String, which may be null.

Parameters
countryCode String

setCountryName

public void setCountryName (String countryName)

Sets the country name of the address to the given String, which may be null.

Parameters
countryName String

setExtras

public void setExtras (Bundle extras)

Sets the extra information associated with this fix to the given Bundle.

Parameters
extras Bundle

setFeatureName

public void setFeatureName (String featureName)

Sets the feature name of the address to the given String, which may be null

Parameters
featureName String

setLatitude

public void setLatitude (double latitude)

Sets the latitude associated with this address.

Parameters
latitude double

setLocality

public void setLocality (String locality)

Sets the locality of the address to the given String, which may be null.

Parameters
locality String

setLongitude

public void setLongitude (double longitude)

Sets the longitude associated with this address.

Parameters
longitude double

setPhone

public void setPhone (String phone)

Sets the phone number associated with this address.

Parameters
phone String

setPostalCode

public void setPostalCode (String postalCode)

Sets the postal code of the address to the given String, which may be null.

Parameters
postalCode String

setPremises

public void setPremises (String premises)

Sets the premises of the address to the given String, which may be null.

Parameters
premises String

setSubAdminArea

public void setSubAdminArea (String subAdminArea)

Sets the sub-administrative area name of the address to the given String, which may be null

Parameters
subAdminArea String

setSubLocality

public void setSubLocality (String sublocality)

Sets the sub-locality of the address to the given String, which may be null.

Parameters
sublocality String

setSubThoroughfare

public void setSubThoroughfare (String subthoroughfare)

Sets the sub-thoroughfare name of the address, which may be null.

Parameters
subthoroughfare String

setThoroughfare

public void setThoroughfare (String thoroughfare)

Sets the thoroughfare name of the address, which may be null.

Parameters
thoroughfare String

setUrl

public void setUrl (String Url)

Sets the public URL associated with this address.

Parameters
Url String

toString

public String toString ()

Returns a string representation of the object.

Returns
String a string representation of the object.