to top
Android APIs
public class

Address

extends Object
implements Parcelable
java.lang.Object
   ↳ android.location.Address

Class Overview

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

Summary

[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final Creator< Address> CREATOR
Public Constructors

? Examples
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

? Examples
void clearLatitude()
Removes any latitude associated with this address.

? Examples
void clearLongitude()
Removes any longitude associated with this address.

? Examples
int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.

? Examples
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.

? Examples
String getAdminArea()
Returns the administrative area name of the address, for example, "CA", or null if it is unknown

? Examples
String getCountryCode()
Returns the country code of the address, for example "US", or null if it is unknown.

? Examples
String getCountryName()
Returns the localized country name of the address, for example "Iceland", or null if it is unknown.

? Examples
Bundle getExtras()
Returns additional provider-specific information about the address as a Bundle.

? Examples
String getFeatureName()
Returns the feature name of the address, for example, "Golden Gate Bridge", or null if it is unknown

? Examples
double getLatitude()
Returns the latitude of the address if known.

? Examples
Locale getLocale()
Returns the Locale associated with this address.

? Examples
String getLocality()
Returns the locality of the address, for example "Mountain View", or null if it is unknown.

? Examples
double getLongitude()
Returns the longitude of the address if known.

? Examples
int getMaxAddressLineIndex()
Returns the largest index currently in use to specify an address line.

? Examples
String getPhone()
Returns the phone number of the address if known, or null if it is unknown.

? Examples
String getPostalCode()
Returns the postal code of the address, for example "94110", or null if it is unknown.

? Examples
String getPremises()
Returns the premises of the address, or null if it is unknown.

? Examples
String getSubAdminArea()
Returns the sub-administrative area name of the address, for example, "Santa Clara County", or null if it is unknown

? Examples
String getSubLocality()
Returns the sub-locality of the address, or null if it is unknown.

? Examples
String getSubThoroughfare()
Returns the sub-thoroughfare name of the address, which may be null.

? Examples
String getThoroughfare()
Returns the thoroughfare name of the address, for example, "1600 Ampitheater Parkway", which may be null

? Examples
String getUrl()
Returns the public URL for the address if known, or null if it is unknown.

? Examples
boolean hasLatitude()
Returns true if a latitude has been assigned to this Address, false otherwise.

? Examples
boolean hasLongitude()
Returns true if a longitude has been assigned to this Address, false otherwise.

? Examples
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.

? Examples
void setAdminArea( String adminArea)
Sets the administrative area name of the address to the given String, which may be null

? Examples
void setCountryCode( String countryCode)
Sets the country code of the address to the given String, which may be null.

? Examples
void setCountryName( String countryName)
Sets the country name of the address to the given String, which may be null.

? Examples
void setExtras( Bundle extras)
Sets the extra information associated with this fix to the given Bundle.

? Examples
void setFeatureName( String featureName)
Sets the feature name of the address to the given String, which may be null

? Examples
void setLatitude(double latitude)
Sets the latitude associated with this address.

? Examples
void setLocality( String locality)
Sets the locality of the address to the given String, which may be null.

? Examples
void setLongitude(double longitude)
Sets the longitude associated with this address.

? Examples
void setPhone( String phone)
Sets the phone number associated with this address.

? Examples
void setPostalCode( String postalCode)
Sets the postal code of the address to the given String, which may be null.

? Examples
void setPremises( String premises)
Sets the premises of the address to the given String, which may be null.

? Examples
void setSubAdminArea( String subAdminArea)
Sets the sub-administrative area name of the address to the given String, which may be null

? Examples
void setSubLocality( String sublocality)
Sets the sub-locality of the address to the given String, which may be null.

? Examples
void setSubThoroughfare( String subthoroughfare)
Sets the sub-thoroughfare name of the address, which may be null.

? Examples
void setThoroughfare( String thoroughfare)
Sets the thoroughfare name of the address, which may be null.

? Examples
void setUrl( String Url)
Sets the public URL associated with this address.

? Examples
String toString()
Returns a string containing a concise, human-readable description of this object.

? Examples
void writeToParcel( Parcel parcel, int flags)
Flatten this object in to a Parcel.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Fields

public static final Creator<Address> CREATOR

Added in API level 1

Public Constructors

public Address (Locale locale)

Added in API level 1

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

Public Methods

public void clearLatitude ()

Added in API level 1

Removes any latitude associated with this address.

public void clearLongitude ()

Added in API level 1

Removes any longitude associated with this address.

public int describeContents ()

Added in API level 1

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

Returns
  • a bitmask indicating the set of special object types marshalled by the Parcelable.

public String getAddressLine (int index)

Added in API level 1

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

Throws
IllegalArgumentException if index < 0

public String getAdminArea ()

Added in API level 1

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

public String getCountryCode ()

Added in API level 1

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

public String getCountryName ()

Added in API level 1

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

public Bundle getExtras ()

Added in API level 1

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.

public String getFeatureName ()

Added in API level 1

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

public double getLatitude ()

Added in API level 1

Returns the latitude of the address if known.

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

public Locale getLocale ()

Added in API level 1

Returns the Locale associated with this address.

public String getLocality ()

Added in API level 1

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

public double getLongitude ()

Added in API level 1

Returns the longitude of the address if known.

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

public int getMaxAddressLineIndex ()

Added in API level 1

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

public String getPhone ()

Added in API level 1

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

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

public String getPostalCode ()

Added in API level 1

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

public String getPremises ()

Added in API level 4

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

public String getSubAdminArea ()

Added in API level 1

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

public String getSubLocality ()

Added in API level 4

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

public String getSubThoroughfare ()

Added in API level 4

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

public String getThoroughfare ()

Added in API level 1

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

public String getUrl ()

Added in API level 1

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

public boolean hasLatitude ()

Added in API level 1

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

public boolean hasLongitude ()

Added in API level 1

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

public void setAddressLine (int index, String line)

Added in API level 1

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

Throws
IllegalArgumentException if index < 0

public void setAdminArea (String adminArea)

Added in API level 1

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

public void setCountryCode (String countryCode)

Added in API level 1

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

public void setCountryName (String countryName)

Added in API level 1

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

public void setExtras (Bundle extras)

Added in API level 1

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

public void setFeatureName (String featureName)

Added in API level 1

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

public void setLatitude (double latitude)

Added in API level 1

Sets the latitude associated with this address.

public void setLocality (String locality)

Added in API level 1

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

public void setLongitude (double longitude)

Added in API level 1

Sets the longitude associated with this address.

public void setPhone (String phone)

Added in API level 1

Sets the phone number associated with this address.

public void setPostalCode (String postalCode)

Added in API level 1

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

public void setPremises (String premises)

Added in API level 4

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

public void setSubAdminArea (String subAdminArea)

Added in API level 1

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

public void setSubLocality (String sublocality)

Added in API level 4

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

public void setSubThoroughfare (String subthoroughfare)

Added in API level 4

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

public void setThoroughfare (String thoroughfare)

Added in API level 1

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

public void setUrl (String Url)

Added in API level 1

Sets the public URL associated with this address.

public String toString ()

Added in API level 1

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

Returns
  • a printable representation of this object.

public void writeToParcel (Parcel parcel, int flags)

Added in API level 1

Flatten this object in to a Parcel.

Parameters
parcel The Parcel in which the object should be written.
flags Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.
No examples for this method.
Frequently called with: [Clear]
Portions of this page are reproduced from work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License. The original page is available here.