in

java: ciudades o pueblos cercanos a mi ubicación actual

apple touch icon@2

Aquí hay un ejemplo:

https://github.com/yangjiandong/proAndroid4DevCode/blob/master/Full%20Worked%20Sample%20Projects/Chapter_13_Where_Am_I_Part_3/src/com/paad/whereami/WhereAmI.java#L14

     private void updateWithNewLocation(Location location) {
    TextView myLocationText;
    myLocationText = (TextView)findViewById(R.id.myLocationText);

    String latLongString = "No location found";
    String addressString = "No address found";

    if (location != null) {
      double lat = location.getLatitude();
      double lng = location.getLongitude();
      latLongString = "Lat:" + lat + "nLong:" + lng;

      double latitude = location.getLatitude();
      double longitude = location.getLongitude();
      Geocoder gc = new Geocoder(this, Locale.getDefault());

      try {
        List<Address> addresses = gc.getFromLocation(latitude, longitude, 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.getLocality()).append("n");
          sb.append(address.getPostalCode()).append("n");
          sb.append(address.getCountryName());
        }
        addressString = sb.toString();
      } catch (IOException e) {}
    }

    myLocationText.setText("Your Current Position is:n" +
                            latLongString + "nn" + addressString);
  }

  private final LocationListener locationListener = new LocationListener() {
    public void onLocationChanged(Location location) {
      updateWithNewLocation(location);
    }

Deja una respuesta

Tu dirección de correo electrónico no será publicada.

Función de biblioteca C – fflush ()

gfg 200x200 min

función median () en el módulo de estadísticas de Python