use of android.location.CountryDetector in project android_frameworks_base by ParanoidAndroid.
the class CallerInfo method getCurrentCountryIso.
/**
* @return The ISO 3166-1 two letters country code of the country the user
* is in.
*/
private static String getCurrentCountryIso(Context context, Locale locale) {
String countryIso;
CountryDetector detector = (CountryDetector) context.getSystemService(Context.COUNTRY_DETECTOR);
if (detector != null) {
countryIso = detector.detectCountry().getCountryIso();
} else {
countryIso = locale.getCountry();
Rlog.w(TAG, "No CountryDetector; falling back to countryIso based on locale: " + countryIso);
}
return countryIso;
}
use of android.location.CountryDetector in project platform_frameworks_base by android.
the class CallerInfo method getCurrentCountryIso.
/**
* @return The ISO 3166-1 two letters country code of the country the user
* is in.
*/
private static String getCurrentCountryIso(Context context, Locale locale) {
String countryIso = null;
CountryDetector detector = (CountryDetector) context.getSystemService(Context.COUNTRY_DETECTOR);
if (detector != null) {
Country country = detector.detectCountry();
if (country != null) {
countryIso = country.getCountryIso();
} else {
Rlog.e(TAG, "CountryDetector.detectCountry() returned null.");
}
}
if (countryIso == null) {
countryIso = locale.getCountry();
Rlog.w(TAG, "No CountryDetector; falling back to countryIso based on locale: " + countryIso);
}
return countryIso;
}
use of android.location.CountryDetector in project XobotOS by xamarin.
the class PhoneNumberUtils method isLocalEmergencyNumber.
/**
* Checks if a given number is an emergency number for the country that the user is in. The
* current country is determined using the CountryDetector.
*
* @param number the number to look up.
* @param context the specific context which the number should be checked against
* @return if a phone number is an emergency number for a local country, based on the
* CountryDetector.
* @see android.location.CountryDetector
* @hide
*/
public static boolean isLocalEmergencyNumber(String number, Context context) {
String countryIso;
CountryDetector detector = (CountryDetector) context.getSystemService(Context.COUNTRY_DETECTOR);
if (detector != null) {
countryIso = detector.detectCountry().getCountryIso();
} else {
Locale locale = context.getResources().getConfiguration().locale;
countryIso = locale.getCountry();
Log.w(LOG_TAG, "No CountryDetector; falling back to countryIso based on locale: " + countryIso);
}
return isEmergencyNumber(number, countryIso);
}
use of android.location.CountryDetector in project XobotOS by xamarin.
the class CallerInfo method getCurrentCountryIso.
/**
* @return The ISO 3166-1 two letters country code of the country the user
* is in.
*/
private static String getCurrentCountryIso(Context context, Locale locale) {
String countryIso;
CountryDetector detector = (CountryDetector) context.getSystemService(Context.COUNTRY_DETECTOR);
if (detector != null) {
countryIso = detector.detectCountry().getCountryIso();
} else {
countryIso = locale.getCountry();
Log.w(TAG, "No CountryDetector; falling back to countryIso based on locale: " + countryIso);
}
return countryIso;
}
use of android.location.CountryDetector in project android_frameworks_base by DirtyUnicorns.
the class CallerInfo method getCurrentCountryIso.
/**
* @return The ISO 3166-1 two letters country code of the country the user
* is in.
*/
private static String getCurrentCountryIso(Context context, Locale locale) {
String countryIso = null;
CountryDetector detector = (CountryDetector) context.getSystemService(Context.COUNTRY_DETECTOR);
if (detector != null) {
Country country = detector.detectCountry();
if (country != null) {
countryIso = country.getCountryIso();
} else {
Rlog.e(TAG, "CountryDetector.detectCountry() returned null.");
}
}
if (countryIso == null) {
countryIso = locale.getCountry();
Rlog.w(TAG, "No CountryDetector; falling back to countryIso based on locale: " + countryIso);
}
return countryIso;
}
Aggregations