use of android.location.Country in project android_frameworks_base by DirtyUnicorns.
the class LocationBasedCountryDetector method queryCountryCode.
/**
* Start a new thread to query the country from Geocoder.
*/
private synchronized void queryCountryCode(final Location location) {
if (location == null) {
notifyListener(null);
return;
}
if (mQueryThread != null)
return;
mQueryThread = new Thread(new Runnable() {
@Override
public void run() {
String countryIso = null;
if (location != null) {
countryIso = getCountryFromLocation(location);
}
if (countryIso != null) {
mDetectedCountry = new Country(countryIso, Country.COUNTRY_SOURCE_LOCATION);
} else {
mDetectedCountry = null;
}
notifyListener(mDetectedCountry);
mQueryThread = null;
}
});
mQueryThread.start();
}
use of android.location.Country in project android_frameworks_base by AOSPA.
the class CountryDetectorService method initialize.
private void initialize() {
mCountryDetector = new ComprehensiveCountryDetector(mContext);
mLocationBasedDetectorListener = new CountryListener() {
public void onCountryDetected(final Country country) {
mHandler.post(new Runnable() {
public void run() {
notifyReceivers(country);
}
});
}
};
}
use of android.location.Country in project android_frameworks_base by AOSPA.
the class ComprehensiveCountryDetector method getCountry.
/**
* Get the country from different sources in order of the reliability.
*/
private Country getCountry() {
Country result = null;
result = getNetworkBasedCountry();
if (result == null) {
result = getLastKnownLocationBasedCountry();
}
if (result == null) {
result = getSimBasedCountry();
}
if (result == null) {
result = getLocaleCountry();
}
addToLogs(result);
return result;
}
use of android.location.Country in project android_frameworks_base by AOSPA.
the class ComprehensiveCountryDetector method detectCountry.
/**
* @param notifyChange indicates whether the listener should be notified the change of the
* country
* @param startLocationBasedDetection indicates whether the LocationBasedCountryDetector could
* be started if the current country source is less reliable than the location.
* @return the current available UserCountry
*/
private Country detectCountry(boolean notifyChange, boolean startLocationBasedDetection) {
Country country = getCountry();
runAfterDetectionAsync(mCountry != null ? new Country(mCountry) : mCountry, country, notifyChange, startLocationBasedDetection);
mCountry = country;
return mCountry;
}
use of android.location.Country in project android_frameworks_base by AOSPA.
the class LocationBasedCountryDetector method queryCountryCode.
/**
* Start a new thread to query the country from Geocoder.
*/
private synchronized void queryCountryCode(final Location location) {
if (location == null) {
notifyListener(null);
return;
}
if (mQueryThread != null)
return;
mQueryThread = new Thread(new Runnable() {
@Override
public void run() {
String countryIso = null;
if (location != null) {
countryIso = getCountryFromLocation(location);
}
if (countryIso != null) {
mDetectedCountry = new Country(countryIso, Country.COUNTRY_SOURCE_LOCATION);
} else {
mDetectedCountry = null;
}
notifyListener(mDetectedCountry);
mQueryThread = null;
}
});
mQueryThread.start();
}
Aggregations