How to get the actual address from a Location on Android
<p>I want to get the address of location, I tried:</p>

<pre><code>package com.spot.prototype;

import android.os.Bundle;
import android.view.KeyEvent;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.Overlay;

import android.content.Context;
import android.view.MotionEvent;
import android.widget.Toast;

import android.location.Geocoder;
import android.location.Address;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;

import java.io.IOException;
import java.util.List;
import java.util.Locale;

public class SpotActivity extends MapActivity {
    MapView mapView;
    MapController mc;
    GeoPoint p;

    private LocationManager lm;
    private LocationListener locationListener;

    @Override
    public void onCreate( Bundle savedInstanceState ) {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.main );
        mapView = ( MapView ) findViewById( R.id.mapView );
        mapView.setBuiltInZoomControls( true );
        // mapView.setSatellite(true);
        // mapView.setStreetView(true);
        mc = mapView.getController();
        String coordinates[] = { "1.352566007", "103.78921587" };
        double lat = Double.parseDouble( coordinates[0] );
        double lng = Double.parseDouble( coordinates[1] );
        p = new GeoPoint( ( int ) ( lat * 1E6 ), ( int ) ( lng * 1E6 ) );
        mc.animateTo( p );
        mc.setZoom( 13 );

        lm = ( LocationManager ) getSystemService( Context.LOCATION_SERVICE );
        locationListener = new MyLocationListener();
        lm.requestLocationUpdates( LocationManager.GPS_PROVIDER, 200, 10, locationListener );
    }

    public boolean onKeyDown( int keyCode, KeyEvent event ) {
        MapController mc = mapView.getController();
        switch( keyCode ) {
        case KeyEvent.KEYCODE_3 :
            mc.zoomIn();
            break;
        case KeyEvent.KEYCODE_1 :
            mc.zoomOut();
            break;
        }
        return super.onKeyDown( keyCode, event );
    }



    private class MyLocationListener implements LocationListener {
        @Override
        public void onLocationChanged( Location loc ) {
            if ( loc != null ) {
                Geocoder geoCoder = new Geocoder( getBaseContext(), Locale.getDefault() );
                try {
                    List&lt;Address&gt; addresses = geoCoder.getFromLocation( loc.getLatitude(), loc.getLongitude(), 1 );
                    System.out.println( loc.getLatitude() );
                    System.out.println( loc.getLongitude() );
                    String add = "";
                    if ( addresses.size() &gt; 0 ) {
                        for( int i = 0; i &lt; addresses.get( 0 ) .getMaxAddressLineIndex(); ++i ) {
                            add += addresses.get( 0 ).getAddressLine( i ) + "\n";
                        }
                    }

                    Toast.makeText( getBaseContext(), add, Toast.LENGTH_SHORT ) .show();

                }  
                catch( IOException e ) {
                    e.printStackTrace();
                }
            }
        }

        @Override
        public void onProviderDisabled( String provider ) {
        }

        @Override
        public void onProviderEnabled( String provider ) {
        }

        @Override
        public void onStatusChanged( String provider, int status, Bundle extras ) {
        }
    }

    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }
}
</code></pre>

<p>While sending signal to my emulator, I see location was actually updated. However, the List of address is always <code>null</code>. Can anyone shed me some light on this? Thanks in advance.</p>
