public class ComprehensiveCountryDetector extends CountryDetectorBase
Call the detectCountry()
to get the available country immediately.
To be notified of the future country change, using the
setCountryListener(CountryListener)
Using the stop()
to stop listening to the country change.
The country information will be refreshed every
LOCATION_REFRESH_INTERVAL
once the location based country is used.
Modifier and Type | Field and Description |
---|---|
protected CountryDetectorBase |
mLocationBasedCountryDetector |
protected Timer |
mLocationRefreshTimer |
mContext, mDetectedCountry, mHandler, mListener
Constructor and Description |
---|
ComprehensiveCountryDetector(Context context) |
Modifier and Type | Method and Description |
---|---|
protected void |
addPhoneStateListener() |
protected CountryDetectorBase |
createLocationBasedCountryDetector() |
Country |
detectCountry()
Start detecting the country that the user is in.
|
protected Country |
getLastKnownLocationBasedCountry() |
protected Country |
getLocaleCountry() |
protected Country |
getNetworkBasedCountry() |
protected Country |
getSimBasedCountry() |
protected boolean |
isAirplaneModeOff() |
protected boolean |
isGeoCoderImplemented() |
protected void |
removePhoneStateListener() |
protected void |
runAfterDetectionAsync(Country country,
Country detectedCountry,
boolean notifyChange,
boolean startLocationBasedDetection)
Run the tasks in the service's thread.
|
void |
setCountryListener(CountryListener listener)
Register a listener to receive the notification when the country is detected or changed.
|
void |
stop()
Stop detecting the country.
|
String |
toString()
Returns a string representation of the object.
|
notifyListener
protected CountryDetectorBase mLocationBasedCountryDetector
protected Timer mLocationRefreshTimer
public ComprehensiveCountryDetector(Context context)
public Country detectCountry()
CountryDetectorBase
detectCountry
in class CountryDetectorBase
public void stop()
CountryDetectorBase
stop
in class CountryDetectorBase
protected Country getNetworkBasedCountry()
protected Country getLastKnownLocationBasedCountry()
protected Country getSimBasedCountry()
protected Country getLocaleCountry()
protected void runAfterDetectionAsync(Country country, Country detectedCountry, boolean notifyChange, boolean startLocationBasedDetection)
public void setCountryListener(CountryListener listener)
CountryDetectorBase
The previous listener will be replaced if it exists.
setCountryListener
in class CountryDetectorBase
protected CountryDetectorBase createLocationBasedCountryDetector()
protected boolean isAirplaneModeOff()
protected void addPhoneStateListener()
protected void removePhoneStateListener()
protected boolean isGeoCoderImplemented()
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())