当前位置: 首页>>代码示例>>Java>>正文


Java Address.getAddressLine方法代码示例

本文整理汇总了Java中android.location.Address.getAddressLine方法的典型用法代码示例。如果您正苦于以下问题:Java Address.getAddressLine方法的具体用法?Java Address.getAddressLine怎么用?Java Address.getAddressLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.location.Address的用法示例。


在下文中一共展示了Address.getAddressLine方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAddress

import android.location.Address; //导入方法依赖的package包/类
public String getAddress(Context context, double lat, double lng) {
    Geocoder geocoder = new Geocoder(context, Locale.getDefault());
    try {
        List<Address> addresses = geocoder.getFromLocation(lat, lng, 1);
        Address obj = addresses.get(0);

        String add = obj.getAddressLine(0);
        add = add + "," + obj.getAdminArea();
        add = add + "," + obj.getCountryName();

        return add;
    } catch (IOException e) {
        e.printStackTrace();
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
        return null;
    }
}
 
开发者ID:LewisVo,项目名称:Overkill,代码行数:18,代码来源:MapsActivity2.java

示例2: formatAddress

import android.location.Address; //导入方法依赖的package包/类
@NonNull
private static String formatAddress(@NonNull Address address) {
    String addressText = "";
    String streetAndNumber = address.getAddressLine(0);
    if (!(streetAndNumber == null || streetAndNumber.isEmpty())) {
        addressText += streetAndNumber;
    }
    String locality = address.getLocality();
    if (locality != null) {
        if (!(addressText.isEmpty() || addressText.trim().endsWith(","))) {
            addressText += ", ";
        }
        addressText += locality;
    }
    return addressText;
}
 
开发者ID:ArnauBlanch,项目名称:civify-app,代码行数:17,代码来源:GeocoderAdapter.java

示例3: updateMemoryPosition

import android.location.Address; //导入方法依赖的package包/类
private void updateMemoryPosition(Memory memory, LatLng latLng) {
    Geocoder geocoder = new Geocoder(this);
    List<Address> matches = null;
    try {
        matches = geocoder.getFromLocation(latLng.latitude, latLng.longitude, 1);
    } catch (IOException e) {
        e.printStackTrace();
    }

    Address bestMatch = (matches.isEmpty()) ? null : matches.get(0);
    int maxLine = bestMatch.getMaxAddressLineIndex();
    memory.city = bestMatch.getAddressLine(maxLine - 1);
    memory.country = bestMatch.getAddressLine(maxLine);
    memory.latitude = latLng.latitude;
    memory.longitude = latLng.longitude;
}
 
开发者ID:PacktPublishing,项目名称:Android-Wear-Projects,代码行数:17,代码来源:MapsActivity.java

示例4: getAddressLine

import android.location.Address; //导入方法依赖的package包/类
/**
 * Try to get AddressLine
 * @return null or addressLine
 */
public String getAddressLine(Context context)
{
    List<Address> addresses = getGeocoderAddress(context);
    if (addresses != null && addresses.size() > 0)
    {
        Address address = addresses.get(0);
        String addressLine = address.getAddressLine(0);

        return addressLine;
    }
    else
    {
        return null;
    }
}
 
开发者ID:SkylineLabs,项目名称:FindX,代码行数:20,代码来源:digiPune.java

示例5: call

import android.location.Address; //导入方法依赖的package包/类
@Override
public String call(Address address) {
    if (address == null) return "";

    String addressLines = "";
    for (int i = 0; i <= address.getMaxAddressLineIndex(); i++) {
        addressLines += address.getAddressLine(i) + '\n';
    }
    return addressLines;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:AddressToStringFunc.java

示例6: 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();
    }
}
 
开发者ID:victorySSS,项目名称:readingNotes,代码行数:16,代码来源:LocationUtil.java

示例7: addressToString

import android.location.Address; //导入方法依赖的package包/类
public static String addressToString(Address address) {
   	StringBuilder sb = new StringBuilder();
   	int max = address.getMaxAddressLineIndex();
   	for (int i = max; i >= 0; i--) {
   		String line = address.getAddressLine(i);
   		if (i < max) {
   			sb.append(", ");        			
   		}
   		sb.append(line);
   	}
   	return sb.toString();
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:13,代码来源:AddressGeocoder.java

示例8: getFromLocation

import android.location.Address; //导入方法依赖的package包/类
public String getFromLocation(double lat, double lng) {
    String result = "";
    List<Address> addresses = null;
    try {
        addresses = geocoder.getFromLocation(lat, lng, 1);
        Address address = addresses.get(0);

        for(int i = 0; i < address.getMaxAddressLineIndex(); i++) {
            result += address.getAddressLine(i) + ", ";
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}
 
开发者ID:micromasterandroid,项目名称:androidadvanced,代码行数:16,代码来源:Util.java

示例9: onHandleIntent

import android.location.Address; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {

    Geocoder geoCoder = new Geocoder(this, Locale.getDefault());

    List<Address> addresses = null;
    resultReceiver = intent.getParcelableExtra(Constants.RECEIVER);
    Location mLocation = intent.getParcelableExtra(Constants.LOCATION_DATA_EXTRA);
    try {
        addresses = geoCoder.getFromLocation(mLocation.getLatitude(), mLocation.getLongitude(), 1);
    } catch (Exception e) {
        Log.e(TAG, e.toString());
    }

    if (addresses == null || addresses.size() == 0) {
        if (errorMessage.isEmpty()) {
            errorMessage = "No address found";
            Log.e(TAG, errorMessage);
        }
        deliverResultToReceiver(Constants.FAILURE_RESULT, errorMessage, null);
    } else {
        Address address = addresses.get(0);
        String completeAddress = "";
        for (int i = 1; i <= address.getMaxAddressLineIndex(); i++) {
            completeAddress = completeAddress + (address.getAddressLine(i) + ",");
        }
        if (completeAddress != "") {
            completeAddress=completeAddress.substring(0,completeAddress.length()-1);
        }
        deliverResultToReceiver(Constants.SUCCESS_RESULT, address.getAddressLine(0), completeAddress);
    }

}
 
开发者ID:pmathew92,项目名称:MapsWithPlacesAutoComplete,代码行数:34,代码来源:GeoCoderIntentService.java

示例10: getAddressText

import android.location.Address; //导入方法依赖的package包/类
private String getAddressText(Address address) {
    String addressText = "";
    final int maxAddressLineIndex = address.getMaxAddressLineIndex();

    for (int i = 0; i <= maxAddressLineIndex; i++) {
        addressText += address.getAddressLine(i);
        if (i != maxAddressLineIndex) {
            addressText += "\n";
        }
    }

    return addressText;
}
 
开发者ID:florent37,项目名称:RxGps,代码行数:14,代码来源:MainActivity.java

示例11: 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>";
}
 
开发者ID:aliumujib,项目名称:Nibo,代码行数:14,代码来源:BaseNiboFragment.java

示例12: getStreet

import android.location.Address; //导入方法依赖的package包/类
/**
 * 根据经纬度获取所在街道
 *
 * @param latitude  纬度
 * @param longitude 经度
 * @return 所在街道
 */
public static String getStreet(double latitude, double longitude) {
    Address address = getAddress(latitude, longitude);
    return address == null ? "unknown" : address.getAddressLine(0);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:LocationUtils.java


注:本文中的android.location.Address.getAddressLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。