use of com.android.i18n.phonenumbers.geocoding.PhoneNumberOfflineGeocoder in project android_frameworks_base by ParanoidAndroid.
the class CallerInfo method getGeoDescription.
/**
* @return a geographical description string for the specified number.
* @see com.android.i18n.phonenumbers.PhoneNumberOfflineGeocoder
*/
private static String getGeoDescription(Context context, String number) {
if (VDBG)
Rlog.v(TAG, "getGeoDescription('" + number + "')...");
if (TextUtils.isEmpty(number)) {
return null;
}
PhoneNumberUtil util = PhoneNumberUtil.getInstance();
PhoneNumberOfflineGeocoder geocoder = PhoneNumberOfflineGeocoder.getInstance();
Locale locale = context.getResources().getConfiguration().locale;
String countryIso = getCurrentCountryIso(context, locale);
PhoneNumber pn = null;
try {
if (VDBG)
Rlog.v(TAG, "parsing '" + number + "' for countryIso '" + countryIso + "'...");
pn = util.parse(number, countryIso);
if (VDBG)
Rlog.v(TAG, "- parsed number: " + pn);
} catch (NumberParseException e) {
Rlog.w(TAG, "getGeoDescription: NumberParseException for incoming number '" + number + "'");
}
if (pn != null) {
String description = geocoder.getDescriptionForNumber(pn, locale);
if (VDBG)
Rlog.v(TAG, "- got description: '" + description + "'");
return description;
} else {
return null;
}
}
Aggregations