當前位置: 首頁>>代碼示例>>Java>>正文


Java Address.getCountryName方法代碼示例

本文整理匯總了Java中android.location.Address.getCountryName方法的典型用法代碼示例。如果您正苦於以下問題:Java Address.getCountryName方法的具體用法?Java Address.getCountryName怎麽用?Java Address.getCountryName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.location.Address的用法示例。


在下文中一共展示了Address.getCountryName方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: getCountryName

import android.location.Address; //導入方法依賴的package包/類
/**
 * Try to get CountryName
 * @return null or postalCode
 */
public String getCountryName(Context context)
{
    List<Address> addresses = getGeocoderAddress(context);
    if (addresses != null && addresses.size() > 0)
    {
        Address address = addresses.get(0);
        String countryName = address.getCountryName();

        return countryName;
    }
    else
    {
        return null;
    }
}
 
開發者ID:SkylineLabs,項目名稱:FindX,代碼行數:20,代碼來源:digiPune.java

示例3: getLocalityNameEng

import android.location.Address; //導入方法依賴的package包/類
public static String getLocalityNameEng(Context context, LatLng latLng) {
    Geocoder gcd = new Geocoder(context, Locale.US);
    try {
        List<Address> addresses = gcd.getFromLocation(latLng.latitude, latLng.longitude, 1);
        if (addresses.size() > 0) {
            Address address = addresses.get(0);
            String name = address.getCountryName();
            if (address.getLocality() != null)
                name = address.getLocality();
            return name;
        }
    } catch (IOException ex) {
        Log.d(TAG, Log.getStackTraceString(ex));
    }
    return null;
}
 
開發者ID:sept-en,項目名稱:FlightSight-client,代碼行數:17,代碼來源:Utils.java

示例4: getLocalityName

import android.location.Address; //導入方法依賴的package包/類
@Nullable
public static String getLocalityName(Context context, LatLng latLng) {
    Geocoder gcd = new Geocoder(context, Locale.getDefault());
    try {
        List<Address> addresses = gcd.getFromLocation(latLng.latitude, latLng.longitude, 1);
        if (addresses.size() > 0) {
            Address address = addresses.get(0);
            String name = address.getCountryName();
            if (address.getLocality() != null)
                name = address.getLocality() + ", " + name;
            return name;
        }
    } catch (IOException ex) {
        Log.d(TAG, Log.getStackTraceString(ex));
    }
    return null;
}
 
開發者ID:sept-en,項目名稱:FlightSight-client,代碼行數:18,代碼來源:Utils.java

示例5: 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

示例6: getAddressString

import android.location.Address; //導入方法依賴的package包/類
@android.support.annotation.NonNull
public String getAddressString(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();

    return address + ", " + city + ", " + state + ", " + country + ", " + postalCode;
}
 
開發者ID:aliumujib,項目名稱:Nibo,代碼行數:11,代碼來源:BaseNiboFragment.java

示例7: getCountryName

import android.location.Address; //導入方法依賴的package包/類
/**
 * 根據經緯度獲取所在國家
 *
 * @param latitude  緯度
 * @param longitude 經度
 * @return 所在國家
 */
public static String getCountryName(double latitude, double longitude) {
    Address address = getAddress(latitude, longitude);
    return address == null ? "unknown" : address.getCountryName();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:LocationUtils.java


注:本文中的android.location.Address.getCountryName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。