コード例 #1
0
    public void onClick(final View v) {
      if (GpsUtils.isEnabled(PlacesViewActivity.this)) {
        if (currentPoint == null) {
          android.location.Location lastKnownLocation =
              locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
          if (lastKnownLocation == null) {
            lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
          }
          currentPoint =
              new GeoPoint(
                  (int) (lastKnownLocation.getLatitude() * 1E6),
                  (int) (lastKnownLocation.getLongitude() * 1E6));
          ;
        }

        final PlaceFilter placeFilter = new PlaceFilter();
        placeFilter.setLocation(currentPoint);
        placeFilter.setLanguage("pt-BR");
        placeFilter.setRadius(rangeSeekBar.getProgress());
        placeFilter.setSensor(true);
        if (!typesFilter.isEmpty()) {
          placeFilter.setType(typesFilter);
        }
        executePlaceSearch(placeFilter);
      }
    }
コード例 #2
0
 @Override
 protected void onResume() {
   super.onResume();
   if (myLocationOverlay != null) {
     if (GpsUtils.isEnabled(this)) {
       myLocationOverlay.enableMyLocation();
       // myLocationOverlay.enableCompass();
       locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
     }
   }
 }