FileDocCategorySizeDatePackage
Country.javaAPI DocAndroid 5.1 API6130Thu Mar 12 22:22:30 GMT 2015android.location

Country

public class Country extends Object implements android.os.Parcelable
This class wraps the country information.
hide

Fields Summary
public static final int
COUNTRY_SOURCE_NETWORK
The country code came from the mobile network
public static final int
COUNTRY_SOURCE_LOCATION
The country code came from the location service
public static final int
COUNTRY_SOURCE_SIM
The country code was read from the SIM card
public static final int
COUNTRY_SOURCE_LOCALE
The country code came from the system locale setting
private final String
mCountryIso
The ISO 3166-1 two letters country code.
private final int
mSource
Where the country code came from.
private int
mHashCode
private final long
mTimestamp
Time that this object was created (which we assume to be the time that the source was consulted). This time is in milliseconds since boot up.
public static final Parcelable.Creator
CREATOR
Constructors Summary
public Country(String countryIso, int source)

param
countryIso the ISO 3166-1 two letters country code.
param
source where the countryIso came from, could be one of below values

  • {@link #COUNTRY_SOURCE_NETWORK}
  • {@link #COUNTRY_SOURCE_LOCATION}
  • {@link #COUNTRY_SOURCE_SIM}
  • {@link #COUNTRY_SOURCE_LOCALE}


                                                                                                  
           
        if (countryIso == null || source < COUNTRY_SOURCE_NETWORK
                || source > COUNTRY_SOURCE_LOCALE) {
            throw new IllegalArgumentException();
        }
        mCountryIso = countryIso.toUpperCase(Locale.US);
        mSource = source;
        mTimestamp = SystemClock.elapsedRealtime();
    
private Country(String countryIso, int source, long timestamp)

        if (countryIso == null || source < COUNTRY_SOURCE_NETWORK
                || source > COUNTRY_SOURCE_LOCALE) {
            throw new IllegalArgumentException();
        }
        mCountryIso = countryIso.toUpperCase(Locale.US);
        mSource = source;
        mTimestamp = timestamp;
    
public Country(Country country)

        mCountryIso = country.mCountryIso;
        mSource = country.mSource;
        mTimestamp = country.mTimestamp;
    
Methods Summary
public intdescribeContents()


       
        return 0;
    
public booleanequals(java.lang.Object object)
Returns true if this {@link Country} is equivalent to the given object. This ignores the timestamp value and just checks for equivalence of countryIso and source values. Returns false otherwise.

        if (object == this) {
            return true;
        }
        if (object instanceof Country) {
            Country c = (Country) object;
            // No need to check the equivalence of the timestamp
            return mCountryIso.equals(c.getCountryIso()) && mSource == c.getSource();
        }
        return false;
    
public booleanequalsIgnoreSource(android.location.Country country)
Compare the specified country to this country object ignoring the source and timestamp fields, return true if the countryIso fields are equal

param
country the country to compare
return
true if the specified country's countryIso field is equal to this country's, false otherwise.

        return country != null && mCountryIso.equals(country.getCountryIso());
    
public final java.lang.StringgetCountryIso()

return
the ISO 3166-1 two letters country code

        return mCountryIso;
    
public final intgetSource()

return
where the country code came from, could be one of below values

  • {@link #COUNTRY_SOURCE_NETWORK}
  • {@link #COUNTRY_SOURCE_LOCATION}
  • {@link #COUNTRY_SOURCE_SIM}
  • {@link #COUNTRY_SOURCE_LOCALE}

        return mSource;
    
public final longgetTimestamp()
Returns the time that this object was created (which we assume to be the time that the source was consulted).

        return mTimestamp;
    
public inthashCode()

        int hash = mHashCode;
        if (hash == 0) {
            hash = 17;
            hash = hash * 13 + mCountryIso.hashCode();
            hash = hash * 13 + mSource;
            mHashCode = hash;
        }
        return mHashCode;
    
public java.lang.StringtoString()

        return "Country {ISO=" + mCountryIso + ", source=" + mSource + ", time=" + mTimestamp + "}";
    
public voidwriteToParcel(android.os.Parcel parcel, int flags)

        parcel.writeString(mCountryIso);
        parcel.writeInt(mSource);
        parcel.writeLong(mTimestamp);