本文整理汇总了Java中android.location.Address.getFeatureName方法的典型用法代码示例。如果您正苦于以下问题:Java Address.getFeatureName方法的具体用法?Java Address.getFeatureName怎么用?Java Address.getFeatureName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.location.Address
的用法示例。
在下文中一共展示了Address.getFeatureName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCompleteAddress
import android.location.Address; //导入方法依赖的package包/类
/**
* @param latitude latitude of address
* @param longitude longitude of address
* @return complete address of location
*/
public String getCompleteAddress(double latitude, double longitude) {
String location = "";
try {
Geocoder geocoder = new Geocoder(mContext, Locale.getDefault());
List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
if (addresses.size() > 0) {
Address address = addresses.get(0);
String state, city, zip, street;
if (address.getAdminArea() != null) {
state = address.getAdminArea();
} else {
state = "";
}
if (address.getLocality() != null) {
city = address.getLocality();
} else {
city = "";
}
if (address.getPostalCode() != null) {
zip = address.getPostalCode();
} else {
zip = "";
}
if (address.getThoroughfare() != null) {
street = address.getSubLocality() + "," + address.getThoroughfare();
} else {
street = address.getSubLocality() + "," + address.getFeatureName();
}
location = street + "," + city + "," + zip + "," + state;
}
} catch (IOException e) {
e.printStackTrace();
}
return location;
}
示例2: getLocation
import android.location.Address; //导入方法依赖的package包/类
private void getLocation(Location location) {
Geocoder geocoder = new Geocoder(activity);
try {
List<Address> addresses = geocoder.getFromLocation(
location.getLatitude(), location.getLongitude(), 1);
Address address = addresses.get(0);
String result = address.getAddressLine(1) + address.getFeatureName();
Message message = handler.obtainMessage();
message.what = Configure.LOCATION_MESSAGE_CODE;
message.obj = result;
handler.sendMessage(message);
} catch (IOException e) {
e.printStackTrace();
}
}
示例3: getAddressHTMLText
import android.location.Address; //导入方法依赖的package包/类
@android.support.annotation.NonNull
public String getAddressHTMLText(Address addressObj) {
String address = addressObj.getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex()
String city = addressObj.getLocality();
String state = addressObj.getAdminArea();
String country = addressObj.getCountryName();
String postalCode = addressObj.getPostalCode();
String part1 = addressObj.getFeatureName();
String part2 = address + ", " + city + ", " + state + ", " + country + ", " + postalCode;
return "<b>" + part1 + "</b><label style='color:#ccc'> <br>" + part2 + "</label>";
}