0

場所をテキストビューに出力しようとしています。locationManager.toString() を使用しましたが、android.location.LocationManager@44ee7718 しか出力されません。Los Angeles, CA 90501 のような場所を出力したいと思います。

LocationManager のコード:

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<Address> 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

ボタンのコード:

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);
        }
    });
4

2 に答える 2