Bir Hizmet geocoder ile Konum Adresini Alma Android

oy
1

Ben takip bu Konum Koordinatları ve Adres almak için

Yani burada Onun Her 10 saniye boyunca Güncellemeler Yer enlem ve boylam koordinatlarını alma

Onlarla Konumu Adres birlikte Get çalışıyorum

Burada kullanılması am Adres Get İnş sınıfını

public class Const {

public static String getCompleteAddressString(Context m_context, double LATITUDE, double LONGITUDE) {
    String strAdd = ;
    Geocoder geocoder = new Geocoder(m_context, Locale.getDefault());
    try {
        List<Address> addresses = geocoder.getFromLocation(LATITUDE, LONGITUDE, 1);
        if (addresses != null) {
            Address returnedAddress = addresses.get(0);
            StringBuilder strReturnedAddress = new StringBuilder();

            for (int i = 0; i < returnedAddress.getMaxAddressLineIndex(); i++) {
                strReturnedAddress.append(returnedAddress.getAddressLine(i)).append(\n);
            }
            strAdd = strReturnedAddress.toString();
            Log.v(My Current location add,  + strAdd.toString());
        }
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(m_context, Sorry, Your location cannot be retrieved ! + e.getMessage(), Toast.LENGTH_SHORT).show();

    }
    return strAdd;
}
}

Ve Şimdi de Ana Faaliyet kullanıyorum Adres almak için

private void updateUI() {
mLatitudeTextView.setText(String.format(%s: %f, mLatitudeLabel,
        mCurrentLocation.getLatitude()));
mLongitudeTextView.setText(String.format(%s: %f, mLongitudeLabel,
        mCurrentLocation.getLongitude()));
mLastUpdateTimeTextView.setText(String.format(%s: %s, mLastUpdateTimeLabel,
        mLastUpdateTime));

//For Address

mLocAddTextView.setText(String.format(%s: %s, mLocAddressLabel,
Const.getCompleteAddressString(this, mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude())));
 }

Ama İşte görüntüler hiçbir şey herhangi bir bu sorun ne bana önerebilirsiniz

Oluştur 27/02/2018 saat 07:54
kaynak kullanıcı
Diğer dillerde...                            


1 cevaplar

oy
1

Kişisel Kod mükemmel

Bu deneyin senin Const class

strReturnedAddress .append(returnedAddress.getAddressLine(0)).append("\n");

posta kodunu, yerellik ve ülke .. vs ... kullanımını kullanmak istiyorsanız

List<Address> addresses = geocoder.getFromLocation(LATITUDE, LONGITUDE, 1);
if (addresses != null) {
    Address returnedAddress = addresses.get(0);
    StringBuilder strReturnedAddress = new StringBuilder("");
    for (int i = 0; i < returnedAddress.getMaxAddressLineIndex(); i++) {
                  strReturnedAddress.append(returnedAddress.getAddressLine(i)).append("\n");
    }
        strReturnedAddress .append(returnedAddress.getAddressLine(0)).append("\n");
        strReturnedAddress .append(returnedAddress.getLocality()).append("\n");
        strReturnedAddress .append(returnedAddress.getPostalCode()).append("\n");
        strReturnedAddress .append(returnedAddress.getCountryName());
    strAdd  = strReturnedAddress.toString();
    Log.v("My Current location add", "" + streturnedAddressd.toString());
}

Geocoder adresi izleyin Get Android Geocode Konumu

Cevap 28/02/2018 saat 08:07
kaynak kullanıcı

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more