How do I output the location using gps on Android
<p>I am trying to output the location into a textview.
I have used the locationManager.toString(), but it would only give me the output android.location.LocationManager@44ee7718.
I would like to output the location like Los Angeles, CA 90501.</p>

<p>The code for LocationManager:</p>

<pre><code>LocationManager lm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    //conversion
    Criteria criteria = new Criteria();
    String bp = lm.getBestProvider(criteria, false);
    Location location = lm.getLastKnownLocation(bp);
    double lat = location.getLatitude();
    double lon = location.getLongitude();
    Geocoder gc = new Geocoder(this, Locale.getDefault());
    List&lt;Address&gt; addresses = null;
        try{
            addresses = gc.getFromLocation(lat, lon, 1);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    Address address = addresses.get(0);
    final String ad = address.getAddressLine(0);
    //ends here
</code></pre>

<p>The code for the button:</p>

<pre><code>Red.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent (Intent.ACTION_VIEW);
            intent.putExtra("sms_body", ad);
            intent.setType("vnd.android-dir/mms-sms");
            startActivity(intent);
        }
    });
</code></pre>
