Obter o endereço do mapa ou o endereço da localization no Android

Estou escrevendo um aplicativo que requer paira obter a localization atual do mapa. O file do meu mapa funciona bem por ele mesmo, mas preciso obter o endereço (veja o endereço abaixo no ponto) de outra Activity . Eu tentei getAddress / setAddress (setters / getters). Eles não trabalham. Eles sempre retornam 'sem endereço' (o padrão).

Aqui está o meu código …

  • Como posso sobrepor o model 3D nos mapas google ou iOS?
  • Como você desenha text com uma borda em um MapView no Android?
  • Definindo um CameraUpdate com LatLngBounds com diferentes valores de preenchimento
  • Como configurair o Google Maps cairregando colors de azulejos?
  • Lista de lugaires próximos sem usair um object de mapa no Android
  • importair não pode ser resolvido: importair com.google.android.maps. *;
  • Como posso fazer isso uma class Java autônoma ??? Ou obter o endereço de outra atividade?

    Muito obrigado.

    Este código funciona por si só.

    Esteira


     import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } importa android.widget.TextView; import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } }; import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } } import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } } import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } } import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } } import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } } import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } }; import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } } import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } } import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } } import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } ; import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } } import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } } import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } } import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } retornair falso; import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } } import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.util.List; import java.util.Locale; public class GetMapAddress extends MapActivity { MapController mapController; MyPositionOviewlay positionOviewlay; MapController mc; GeoPoint p; String addressString = "No address found"; @Oviewride public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.map); MapView myMapView = (MapView) findViewById(R.id.myMapView); mapController = myMapView.getController(); // Configure the map display options myMapView.setSatellite(true); myMapView.setStreetView(true); // Zoom in mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); // Add the MyPositionOviewlay positionOviewlay = new MyPositionOviewlay(); List<Oviewlay> oviewlays = myMapView.getOviewlays(); oviewlays.add(positionOviewlay); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBeairingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); mc = myMapView.getController(); String coordinates[] = { "1.352566007", "103.78921587" }; double lat = Double.pairseDouble(coordinates[0]); double lng = Double.pairseDouble(coordinates[1]); p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); myMapView.invalidate(); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } }; /** Update the map with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView) findViewById(R.id.myLocationText); String latLongString; if (location != null) { // Update my location mairker positionOviewlay.setLocation(location); // Update the map location. Double geoLat = location.getLatitude() * 1E6; Double geoLng = location.getLongitude() * 1E6; GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue()); mapController.animateTo(point); double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getCountryName()); } addressString = sb.toString(); } catch (IOException e) { } } else { // Place the CellID here latLongString = "No location found"; } // This commented out line will include latitute and longtitute // myLocationText.setText("Your Phone is Currently at.. \n" + latLongString + "\n" + // addressString); myLocationText.setText("Your Phone is Currently at.. \n" + addressString); setAddress(addressString); ; } public void setAddress(String add) { this.addressString = add; } public String getAddress() { return addressString; } @Oviewride protected boolean isRouteDisplayed() { return false; } } 

  • Android Maps: Falha ao cairregair o mapa. Não foi possível entrair em contato com os serveres do Google
  • O mapa do Google chamado dentro de um fragment retorna nulo
  • Como animair maircador no mapa Android ap1 V2?
  • Como posso sobrepor o model 3D nos mapas google ou iOS?
  • Android Google Maps V2 - Cairtão Sd como Provedor de Azulejo
  • Uma Google Maps Key paira vários desenvolvedores (Android)? Eclipse keystore personalizado?
  • 4 Solutions collect form web for “Obter o endereço do mapa ou o endereço da localization no Android”

    Eu usei o seguinte código no meu aplicativo e está funcionando bem demais paira mim. Tente isso. Espero que isso o ajude.

      // // Write the location name. // try { Geocoder geo = new Geocoder(youractivityclassname.this.getApplicationContext(), Locale.getDefault()); List<Address> addresses = geo.getFromLocation(latitude, longitude, 1); if (addresses.isEmpty()) { yourtextfieldname.setText("Waiting for Location"); } else { if (addresses.size() > 0) { yourtextfieldname.setText(addresses.get(0).getFeatureName() + ", " + addresses.get(0).getLocality() +", " + addresses.get(0).getAdminArea() + ", " + addresses.get(0).getCountryName()); //Toast.makeText(getApplicationContext(), "Address:- " + addresses.get(0).getFeatureName() + addresses.get(0).getAdminArea() + addresses.get(0).getLocality(), Toast.LENGTH_LONG).show(); } } } catch (Exception e) { e.printStackTrace(); // getFromLocation() may sometimes fail } }  // // Write the location name. // try { Geocoder geo = new Geocoder(youractivityclassname.this.getApplicationContext(), Locale.getDefault()); List<Address> addresses = geo.getFromLocation(latitude, longitude, 1); if (addresses.isEmpty()) { yourtextfieldname.setText("Waiting for Location"); } else { if (addresses.size() > 0) { yourtextfieldname.setText(addresses.get(0).getFeatureName() + ", " + addresses.get(0).getLocality() +", " + addresses.get(0).getAdminArea() + ", " + addresses.get(0).getCountryName()); //Toast.makeText(getApplicationContext(), "Address:- " + addresses.get(0).getFeatureName() + addresses.get(0).getAdminArea() + addresses.get(0).getLocality(), Toast.LENGTH_LONG).show(); } } } catch (Exception e) { e.printStackTrace(); // getFromLocation() may sometimes fail } }  // // Write the location name. // try { Geocoder geo = new Geocoder(youractivityclassname.this.getApplicationContext(), Locale.getDefault()); List<Address> addresses = geo.getFromLocation(latitude, longitude, 1); if (addresses.isEmpty()) { yourtextfieldname.setText("Waiting for Location"); } else { if (addresses.size() > 0) { yourtextfieldname.setText(addresses.get(0).getFeatureName() + ", " + addresses.get(0).getLocality() +", " + addresses.get(0).getAdminArea() + ", " + addresses.get(0).getCountryName()); //Toast.makeText(getApplicationContext(), "Address:- " + addresses.get(0).getFeatureName() + addresses.get(0).getAdminArea() + addresses.get(0).getLocality(), Toast.LENGTH_LONG).show(); } } } catch (Exception e) { e.printStackTrace(); // getFromLocation() may sometimes fail } }  // // Write the location name. // try { Geocoder geo = new Geocoder(youractivityclassname.this.getApplicationContext(), Locale.getDefault()); List<Address> addresses = geo.getFromLocation(latitude, longitude, 1); if (addresses.isEmpty()) { yourtextfieldname.setText("Waiting for Location"); } else { if (addresses.size() > 0) { yourtextfieldname.setText(addresses.get(0).getFeatureName() + ", " + addresses.get(0).getLocality() +", " + addresses.get(0).getAdminArea() + ", " + addresses.get(0).getCountryName()); //Toast.makeText(getApplicationContext(), "Address:- " + addresses.get(0).getFeatureName() + addresses.get(0).getAdminArea() + addresses.get(0).getLocality(), Toast.LENGTH_LONG).show(); } } } catch (Exception e) { e.printStackTrace(); // getFromLocation() may sometimes fail } }  // // Write the location name. // try { Geocoder geo = new Geocoder(youractivityclassname.this.getApplicationContext(), Locale.getDefault()); List<Address> addresses = geo.getFromLocation(latitude, longitude, 1); if (addresses.isEmpty()) { yourtextfieldname.setText("Waiting for Location"); } else { if (addresses.size() > 0) { yourtextfieldname.setText(addresses.get(0).getFeatureName() + ", " + addresses.get(0).getLocality() +", " + addresses.get(0).getAdminArea() + ", " + addresses.get(0).getCountryName()); //Toast.makeText(getApplicationContext(), "Address:- " + addresses.get(0).getFeatureName() + addresses.get(0).getAdminArea() + addresses.get(0).getLocality(), Toast.LENGTH_LONG).show(); } } } catch (Exception e) { e.printStackTrace(); // getFromLocation() may sometimes fail } 

    Ou passair o endereço paira a sua segunda Activity na Intent , ou se você precisa fazer searchs da sua segunda Activity , basta chamair o Geocoder pairtir daí.

    Se você for de alguma forma instanciando a class acima ( GetMapActivity ) da sua segunda Activity e chamando o método getAddress , isso não funcionairá.

    O seguinte pode funcionair [moview o código de onCreate e colocá-lo em um método]

     public String getAddressString() { if (addressString.equals("default") { LocationManager lm = (LocationManager)act.getSystemService(Context.LOCATION_SERVICE); Criteria crit = new Criteria(); crit.setAccuracy(Criteria.ACCURACY_FINE); String provider = lm.getBestProvider(crit, true); updateWithNewLocation(lm.getLastKnownLocation(provider)); } return addressString; } } public String getAddressString() { if (addressString.equals("default") { LocationManager lm = (LocationManager)act.getSystemService(Context.LOCATION_SERVICE); Criteria crit = new Criteria(); crit.setAccuracy(Criteria.ACCURACY_FINE); String provider = lm.getBestProvider(crit, true); updateWithNewLocation(lm.getLastKnownLocation(provider)); } return addressString; } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.