List of usage examples for android.location Geocoder Geocoder
public Geocoder(Context context, Locale locale)
From source file:tw.com.geminihsu.app01.fragment.Fragment_Client_Service_test.java
private void getCurrentAddress(double longitude, double latitude) { Geocoder geocoder = new Geocoder(getActivity(), Locale.getDefault()); try {//from w ww. j a v a 2 s. com List<Address> addressList = geocoder.getFromLocation(latitude, longitude, 1); if (addressList != null && addressList.size() > 0) { Address address = addressList.get(0); StringBuilder sb = new StringBuilder(); 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()); result.setLatitude(latitude); result.setLongitude(longitude); result.setCountryName(address.getCountryName()); result.setLocality(address.getLocality()); result.setZipCode(address.getPostalCode()); result.setLocation(sb.toString()); if (address.getCountryCode().equals("TW")) { result.setAddress(address.getAddressLine(0).substring(3, address.getAddressLine(0).length())); result.setLocation(address.getAddressLine(0).substring(3, address.getAddressLine(0).length())); } else { result.setAddress(sb.toString()); result.setLocation(sb.toString()); } curAddress = result.getAddress(); } } catch (IOException e) { Log.e("", "Unable connect to Geocoder", e); } //test = true; }
From source file:me.trashout.fragment.TrashReportOrEditFragment.java
/** * Setup data trash and edit type/* w ww . jav a 2 s . co m*/ * * @param trash * @param cleaned * @param stillHere */ private void setupData(Trash trash, boolean cleaned, boolean stillHere, boolean more, boolean less) { // trashReportTakeImagesText.setText(getTrash() != null ? R.string.take_at_least_1_photos : R.string.take_at_least_2_photos); getTrash(); trashReportTakeImagesText.setText(R.string.trash_create_takeLeastOnePhoto); if (trash != null) { if (cleaned) { trashReportSize.setVisibility(GONE); trashReportSizeContainer.setVisibility(GONE); trashReportType.setVisibility(GONE); trashReportTypeContainer.setVisibility(GONE); trashReportAccessibility.setVisibility(GONE); trashReportAccessibilityCardView.setVisibility(GONE); trashReportStatusStillHereSwitch.setVisibility(GONE); trashReportStatusStillHere.setVisibility(GONE); trashReportStatusCleanedByMeSwitch.setVisibility(View.VISIBLE); trashReportStatusCleanedItSwitch.setChecked(true); trashReportStatusCleanedItSwitch.setClickable(false); trashReportMap.setVisibility(GONE); } else if (stillHere) { trashReportStatus.setVisibility(GONE); trashReportStatusCardView.setVisibility(GONE); trashReportMap.setVisibility(GONE); } else if (more) { trashReportStatus.setVisibility(GONE); trashReportStatusCardView.setVisibility(GONE); trashReportMap.setVisibility(GONE); } else if (less) { trashReportStatus.setVisibility(GONE); trashReportStatusCardView.setVisibility(GONE); trashReportMap.setVisibility(GONE); } if (trash.getSize().equals(Constants.TrashSize.BAG)) { trashReportSizeBagBtn.setSelected(true); } else if (trash.getSize().equals(Constants.TrashSize.WHEELBARROW)) { trashReportSizeWheelbarrowBtn.setSelected(true); } else if (trash.getSize().equals(Constants.TrashSize.CAR)) { trashReportSizeCarBtn.setSelected(true); } if (trash.getTypes() != null && !trash.getTypes().isEmpty()) { trashReportTypeAutomotiveBtn.setSelected(trash.getTypes().contains(Constants.TrashType.AUTOMOTIVE)); trashReportTypeConstructionBtn .setSelected(trash.getTypes().contains(Constants.TrashType.CONSTRUCTION)); trashReportTypeDangerousBtn.setSelected(trash.getTypes().contains(Constants.TrashType.DANGEROUS)); trashReportTypeElectronicBtn.setSelected(trash.getTypes().contains(Constants.TrashType.ELECTRICS)); trashReportTypeHouseholdBtn.setSelected(trash.getTypes().contains(Constants.TrashType.DOMESTIC)); trashReportTypeLiquidBtn.setSelected(trash.getTypes().contains(Constants.TrashType.LIQUID)); trashReportTypeMetalBtn.setSelected(trash.getTypes().contains(Constants.TrashType.METAL)); trashReportTypeOrganicBtn.setSelected(trash.getTypes().contains(Constants.TrashType.ORGANIC)); trashReportTypePlasticBtn.setSelected(trash.getTypes().contains(Constants.TrashType.PLASTIC)); trashReportTypeDeadAnimalsBtn .setSelected(trash.getTypes().contains(Constants.TrashType.DEAD_ANIMALS)); } if (trash.getAccessibility().isByCar()) { trashReportAccessibilityCarSwitch.setChecked(true); } if (trash.getAccessibility().isInCave()) { trashReportAccessibilityInCaveSwitch.setChecked(true); } if (trash.getAccessibility().isUnderWater()) { trashReportAccessibilityUnderWaterSwitch.setChecked(true); } if (trash.getAccessibility().isNotForGeneralCleanup()) { trashReportAccessibilityNotForGeneralCleanupSwitch.setChecked(true); } trashReportPlace.setText(trash.getGps().getArea().getFormatedLocation()); setPosition(trash.getGps().getLat(), trash.getGps().getLng()); } else if (mLastLocation != null) { trashReportStatus.setVisibility(GONE); trashReportStatusCardView.setVisibility(GONE); setPosition(mLastLocation.latitude, mLastLocation.longitude); Geocoder geocoder = new Geocoder(getActivity(), Locale.getDefault()); new GeocoderTask(geocoder, mLastLocation.latitude, mLastLocation.longitude, new GeocoderTask.Callback() { @Override public void onAddressComplete(GeocoderTask.GeocoderResult geocoderResult) { Log.d(TAG, "geocoderResult = " + geocoderResult); if (geocoderResult.getAddress() != null) { trashReportPlace.setText(geocoderResult.getFormattedAddress()); } } }).execute(); } else { trashReportStatus.setVisibility(GONE); trashReportStatusCardView.setVisibility(GONE); trashReportLocationCardView.setVisibility(GONE); } }
From source file:me.trashout.fragment.DashboardFragment.java
/** * Create and return recent activity view * * @param userActivity/* w ww.j a v a2s . c o m*/ * @return */ private View getRecentActivityView(final UserActivity userActivity) { View userActivityView = inflater.inflate(R.layout.item_list_user_activity, null); userActivityView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { TrashDetailFragment trashDetailFragment = TrashDetailFragment .newInstance(Integer.parseInt(userActivity.getId())); getBaseActivity().replaceFragment(trashDetailFragment); } catch (Exception e) { e.printStackTrace(); } } }); ImageView userActivityImage = userActivityView.findViewById(R.id.user_activity_image); ImageView userActivityType = userActivityView.findViewById(R.id.user_activity_type); TextView userActivityName = userActivityView.findViewById(R.id.user_activity_name); TextView userActivityDate = userActivityView.findViewById(R.id.user_activity_date); final TextView userActivityDistance = userActivityView.findViewById(R.id.user_activity_distance); final TextView userActivityPosition = userActivityView.findViewById(R.id.user_activity_position); if (userActivity.getActivity().getImages() != null && !userActivity.getActivity().getImages().isEmpty() && ViewUtils.checkImageStorage(userActivity.getActivity().getImages().get(0))) { Image image = userActivity.getActivity().getImages().get(0); StorageReference mImageRef = FirebaseStorage.getInstance() .getReferenceFromUrl(image.getSmallestImage()); GlideApp.with(this).load(mImageRef).centerCrop().transition(DrawableTransitionOptions.withCrossFade()) .placeholder(R.drawable.ic_image_placeholder_square).into(userActivityImage); } if (Constants.ActivityAction.CREATE.getName().equals(userActivity.getAction())) { userActivityType.setImageResource(Constants.ActivityAction.CREATE.getIconUpdateActionResId()); } else { userActivityType.setImageResource(userActivity.getActivity().getStatus().getIconUpdatehistoryResId()); } String userName = user == null || userActivity.getUserInfo().getUserId() != user.getId() ? (userActivity.getUserInfo().getFirstName() == null || userActivity.getActivity().isAnonymous()) ? getString(R.string.trash_anonymous) : userActivity.getUserInfo().getFirstName() : getString(R.string.home_recentActivity_you).substring(0, 1).toUpperCase() + getString(R.string.home_recentActivity_you).substring(1); if (Constants.ActivityAction.CREATE.getName().equals(userActivity.getAction())) { userActivityName.setText(getString(R.string.reported_activity_placeholder, userName, getString(Constants.ActivityAction.CREATE.getStringUpdateActionResId()).toLowerCase(), getString(R.string.user_activity_title_thisDump), "", "")); } else { userActivityName.setText(getString(R.string.reported_activity_placeholder, userName, getString(userActivity.getActivity().getStatus().getStringUpdateHistoryResId()).toLowerCase(), getString(R.string.user_activity_title_thisDump), getString(R.string.home_recentActivity_as), getString(userActivity.getActivity().getStatus().getStringResId()).toLowerCase())); } userActivityDate.setText(DateTimeUtils.DATE_FORMAT.format(userActivity.getCreated())); if (lastPosition != null) { userActivityDistance.setText(String.format(getString(R.string.distance_away_formatter), (lastPosition != null && userActivity.getPosition() != null) ? PositionUtils.getRoundedFormattedDistance(getActivity(), (int) PositionUtils.computeDistance(lastPosition, userActivity.getPosition())) : "?", getString(R.string.global_distanceAttribute_away))); } else { userActivityDistance.setVisibility(View.GONE); } final Geocoder geocoder = new Geocoder(getActivity(), Locale.getDefault()); new GeocoderTask(geocoder, userActivity.getGps().getLat(), userActivity.getGps().getLng(), new GeocoderTask.Callback() { @Override public void onAddressComplete(GeocoderTask.GeocoderResult geocoderResult) { if (!TextUtils.isEmpty(geocoderResult.getFormattedShortAddress())) { userActivityPosition.setText(geocoderResult.getFormattedShortAddress()); userActivityPosition.setVisibility(View.VISIBLE); } else { userActivityPosition.setVisibility(View.GONE); } } }).execute(); return userActivityView; }
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityCreateOrEditRoute.java
/** gotLocation(andoid.location.Location location) * helping method for the gpsClicked method * fills the acFrom {@link AutoCompleteTextView} field with the gps information * @param location/* www . ja v a 2 s.co m*/ */ public void gotLocation(android.location.Location location) { Geocoder geocoder = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); acFrom.setText(addresses.get(0).getAddressLine(0) + ", " + addresses.get(0).getAddressLine(1)); } catch (IOException e) { Toast.makeText(this, "Problem with GPS, try restarting your device", Toast.LENGTH_LONG).show(); } loadingDialog.dismiss(); }
From source file:org.egov.android.view.activity.CreateComplaintActivity.java
public String getCurrentLocation(double lat, double lng) { String cityName = ""; if (lat == 0 && lng == 0) { return ""; }/*from w w w . j a v a 2 s.c o m*/ Geocoder geocoder = new Geocoder(CreateComplaintActivity.this, Locale.getDefault()); List<Address> addresses; try { addresses = geocoder.getFromLocation(lat, lng, 1); if (addresses.size() > 0) { Address address = addresses.get(0); cityName = address.getThoroughfare(); } } catch (IOException e) { e.printStackTrace(); } return cityName; }
From source file:org.telegram.ui.ThemeActivity.java
private void updateSunTime(Location lastKnownLocation, boolean forceUpdate) { LocationManager locationManager = (LocationManager) ApplicationLoader.applicationContext .getSystemService(Context.LOCATION_SERVICE); if (Build.VERSION.SDK_INT >= 23) { Activity activity = getParentActivity(); if (activity != null) { if (activity.checkSelfPermission( Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { activity.requestPermissions(new String[] { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION }, 2); return; }/*from w w w. j av a 2 s .c om*/ } } if (getParentActivity() != null) { if (!getParentActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS)) { return; } try { LocationManager lm = (LocationManager) ApplicationLoader.applicationContext .getSystemService(Context.LOCATION_SERVICE); if (!lm.isProviderEnabled(LocationManager.GPS_PROVIDER)) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setMessage(LocaleController.getString("GpsDisabledAlert", R.string.GpsDisabledAlert)); builder.setPositiveButton( LocaleController.getString("ConnectingToProxyEnable", R.string.ConnectingToProxyEnable), (dialog, id) -> { if (getParentActivity() == null) { return; } try { getParentActivity().startActivity( new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)); } catch (Exception ignore) { } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); return; } } catch (Exception e) { FileLog.e(e); } } try { lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (lastKnownLocation == null) { lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); } else if (lastKnownLocation == null) { lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER); } } catch (Exception e) { FileLog.e(e); } if (lastKnownLocation == null || forceUpdate) { startLocationUpdate(); if (lastKnownLocation == null) { return; } } Theme.autoNightLocationLatitude = lastKnownLocation.getLatitude(); Theme.autoNightLocationLongitude = lastKnownLocation.getLongitude(); int time[] = SunDate.calculateSunriseSunset(Theme.autoNightLocationLatitude, Theme.autoNightLocationLongitude); Theme.autoNightSunriseTime = time[0]; Theme.autoNightSunsetTime = time[1]; Theme.autoNightCityName = null; Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); Theme.autoNightLastSunCheckDay = calendar.get(Calendar.DAY_OF_MONTH); Utilities.globalQueue.postRunnable(() -> { String name; try { Geocoder gcd = new Geocoder(ApplicationLoader.applicationContext, Locale.getDefault()); List<Address> addresses = gcd.getFromLocation(Theme.autoNightLocationLatitude, Theme.autoNightLocationLongitude, 1); if (addresses.size() > 0) { name = addresses.get(0).getLocality(); } else { name = null; } } catch (Exception ignore) { name = null; } final String nameFinal = name; AndroidUtilities.runOnUIThread(() -> { Theme.autoNightCityName = nameFinal; if (Theme.autoNightCityName == null) { Theme.autoNightCityName = String.format("(%.06f, %.06f)", Theme.autoNightLocationLatitude, Theme.autoNightLocationLongitude); } Theme.saveAutoNightThemeConfig(); if (listView != null) { RecyclerListView.Holder holder = (RecyclerListView.Holder) listView .findViewHolderForAdapterPosition(scheduleUpdateLocationRow); if (holder != null && holder.itemView instanceof TextSettingsCell) { ((TextSettingsCell) holder.itemView).setTextAndValue(LocaleController .getString("AutoNightUpdateLocation", R.string.AutoNightUpdateLocation), Theme.autoNightCityName, false); } } }); }); RecyclerListView.Holder holder = (RecyclerListView.Holder) listView .findViewHolderForAdapterPosition(scheduleLocationInfoRow); if (holder != null && holder.itemView instanceof TextInfoPrivacyCell) { ((TextInfoPrivacyCell) holder.itemView).setText(getLocationSunString()); } if (Theme.autoNightScheduleByLocation && Theme.selectedAutoNightType == Theme.AUTO_NIGHT_TYPE_SCHEDULED) { Theme.checkAutoNightThemeConditions(); } }
From source file:com.almalence.opencam.SavingService.java
protected void addTimestamp(File file, int exif_orientation) { try {//from w w w. j av a 2 s . c om SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); int dateFormat = Integer.parseInt(prefs.getString(ApplicationScreen.sTimestampDate, "0")); boolean abbreviation = prefs.getBoolean(ApplicationScreen.sTimestampAbbreviation, false); int saveGeo = Integer.parseInt(prefs.getString(ApplicationScreen.sTimestampGeo, "0")); int timeFormat = Integer.parseInt(prefs.getString(ApplicationScreen.sTimestampTime, "0")); int separator = Integer.parseInt(prefs.getString(ApplicationScreen.sTimestampSeparator, "0")); String customText = prefs.getString(ApplicationScreen.sTimestampCustomText, ""); int color = Integer.parseInt(prefs.getString(ApplicationScreen.sTimestampColor, "1")); int fontSizeC = Integer.parseInt(prefs.getString(ApplicationScreen.sTimestampFontSize, "80")); String formattedCurrentDate = ""; if (dateFormat == 0 && timeFormat == 0 && customText.equals("") && saveGeo == 0) return; String geoText = ""; // show geo data on time stamp if (saveGeo != 0) { Location l = MLocation.getLocation(getApplicationContext()); if (l != null) { if (saveGeo == 2) { Geocoder geocoder = new Geocoder(MainScreen.getMainContext(), Locale.getDefault()); List<Address> list = geocoder.getFromLocation(l.getLatitude(), l.getLongitude(), 1); if (!list.isEmpty()) { String country = list.get(0).getCountryName(); String locality = list.get(0).getLocality(); String adminArea = list.get(0).getSubAdminArea();// city // localized String street = list.get(0).getThoroughfare();// street // localized String address = list.get(0).getAddressLine(0); // replace street and city with localized name if (street != null) address = street; if (adminArea != null) locality = adminArea; geoText = (country != null ? country : "") + (locality != null ? (", " + locality) : "") + (address != null ? (", \n" + address) : ""); if (geoText.equals("")) geoText = "lat:" + l.getLatitude() + "\nlng:" + l.getLongitude(); } } else geoText = "lat:" + l.getLatitude() + "\nlng:" + l.getLongitude(); } } String dateFormatString = ""; String timeFormatString = ""; String separatorString = "."; String monthString = abbreviation ? "MMMM" : "MM"; switch (separator) { case 0: separatorString = "/"; break; case 1: separatorString = "."; break; case 2: separatorString = "-"; break; case 3: separatorString = " "; break; default: separatorString = " "; } switch (dateFormat) { case 1: dateFormatString = "yyyy" + separatorString + monthString + separatorString + "dd"; break; case 2: dateFormatString = "dd" + separatorString + monthString + separatorString + "yyyy"; break; case 3: dateFormatString = monthString + separatorString + "dd" + separatorString + "yyyy"; break; default: } switch (timeFormat) { case 1: timeFormatString = " hh:mm:ss a"; break; case 2: timeFormatString = " HH:mm:ss"; break; default: } Date currentDate = Calendar.getInstance().getTime(); java.text.SimpleDateFormat simpleDateFormat = new java.text.SimpleDateFormat( dateFormatString + timeFormatString); formattedCurrentDate = simpleDateFormat.format(currentDate); formattedCurrentDate += (customText.isEmpty() ? "" : ("\n" + customText)) + (geoText.isEmpty() ? "" : ("\n" + geoText)); if (formattedCurrentDate.equals("")) return; Bitmap sourceBitmap; Bitmap bitmap; int rotation = 0; Matrix matrix = new Matrix(); if (exif_orientation == ExifInterface.ORIENTATION_ROTATE_90) { rotation = 90; } else if (exif_orientation == ExifInterface.ORIENTATION_ROTATE_180) { rotation = 180; } else if (exif_orientation == ExifInterface.ORIENTATION_ROTATE_270) { rotation = 270; } matrix.postRotate(rotation); BitmapFactory.Options options = new BitmapFactory.Options(); options.inMutable = true; sourceBitmap = BitmapFactory.decodeFile(file.getAbsolutePath(), options); bitmap = Bitmap.createBitmap(sourceBitmap, 0, 0, sourceBitmap.getWidth(), sourceBitmap.getHeight(), matrix, false); sourceBitmap.recycle(); int width = bitmap.getWidth(); int height = bitmap.getHeight(); Paint p = new Paint(); Canvas canvas = new Canvas(bitmap); final float scale = getResources().getDisplayMetrics().density; p.setColor(Color.WHITE); switch (color) { case 0: color = Color.BLACK; p.setColor(Color.BLACK); break; case 1: color = Color.WHITE; p.setColor(Color.WHITE); break; case 2: color = Color.YELLOW; p.setColor(Color.YELLOW); break; } if (width > height) { p.setTextSize(height / fontSizeC * scale + 0.5f); // convert dps // to pixels } else { p.setTextSize(width / fontSizeC * scale + 0.5f); // convert dps // to pixels } p.setTextAlign(Align.RIGHT); drawTextWithBackground(canvas, p, formattedCurrentDate, color, Color.BLACK, width, height); Matrix matrix2 = new Matrix(); matrix2.postRotate(360 - rotation); sourceBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix2, false); bitmap.recycle(); FileOutputStream outStream; outStream = new FileOutputStream(file); sourceBitmap.compress(Bitmap.CompressFormat.JPEG, jpegQuality, outStream); sourceBitmap.recycle(); outStream.flush(); outStream.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } catch (OutOfMemoryError e) { e.printStackTrace(); } }
From source file:com.instiwork.RegistrationFacebookActivity.java
private void enableMyLocation() { if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { PermissionUtils.requestPermission(this, MY_PERMISSIONS_REQUEST_READ, android.Manifest.permission.ACCESS_FINE_LOCATION, false); } else {// w w w. jav a 2 s.c o m mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); if (mLastLocation != null) { LOCATION_LATITUDE = "" + mLastLocation.getLatitude(); LOCATION_LONGITUDE = "" + mLastLocation.getLongitude(); try { Geocoder geocoder = new Geocoder(RegistrationFacebookActivity.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(mLastLocation.getLatitude(), mLastLocation.getLongitude(), 1); // Here 1 represent max location result to returned, by documents it recommended 1 to 5 currentCountry = "" + addresses.get(0).getCountryName(); } catch (Exception e) { e.printStackTrace(); } getCountryList(); } } }
From source file:com.instiwork.RegistrationFacebookActivity.java
@Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode != MY_PERMISSIONS_REQUEST_READ) { return;//w w w.ja va2s. c om } try { mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); if (mLastLocation != null) { LOCATION_LATITUDE = "" + mLastLocation.getLatitude(); LOCATION_LONGITUDE = "" + mLastLocation.getLongitude(); try { Geocoder geocoder = new Geocoder(RegistrationFacebookActivity.this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(mLastLocation.getLatitude(), mLastLocation.getLongitude(), 1); // Here 1 represent max location result to returned, by documents it recommended 1 to 5 currentCountry = "" + addresses.get(0).getCountryName(); } catch (Exception e) { e.printStackTrace(); } getCountryList(); } } catch (SecurityException e) { e.printStackTrace(); } }
From source file:org.mozilla.gecko.GeckoApp.java
public void onLocationChanged(Location location) { Log.w(LOGTAG, "onLocationChanged " + location); if (mGeocoder == null) mGeocoder = new Geocoder(mLayerController.getView().getContext(), Locale.getDefault()); if (mLastGeoAddress == null) { GeckoAppShell.getHandler().post(new GeocoderRunnable(location)); } else {/*from ww w .ja v a 2 s .c o m*/ float[] results = new float[1]; Location.distanceBetween(location.getLatitude(), location.getLongitude(), mLastGeoAddress.getLatitude(), mLastGeoAddress.getLongitude(), results); // pfm value. don't want to slam the // geocoder with very similar values, so // only call after about 100m if (results[0] > 100) GeckoAppShell.getHandler().post(new GeocoderRunnable(location)); } GeckoAppShell.sendEventToGecko(GeckoEvent.createLocationEvent(location, mLastGeoAddress)); }