@Override
    public boolean onContextItemSelected(final MenuItem item) {
        final int itemId = item.getItemId();
        if (itemId == R.id.menu_waypoint_edit) {
            // waypoints
            if (selectedWaypoint != null) {
                ensureSaved();
                EditWaypointActivity.startActivityEditWaypoint(this, cache, selectedWaypoint.getId());
                setNeedsRefresh();
            }
        } else if (itemId == R.id.menu_waypoint_geofence) {
            if (selectedWaypoint != null) {
                ensureSaved();
                SimpleDialog.of(this)
                        .setTitle(TextParam.id(R.string.waypoint_geofence))
                        .setMessage(TextParam.id(R.string.waypoint_geofence_summary))
                        .input(
                                new SimpleDialog.InputOptions().setInitialValue(String.valueOf(selectedWaypoint.getGeofence())).setInputType(InputType.TYPE_CLASS_NUMBER),
                                result -> {
                                    float newValue = 0;
                                    try {
                                        newValue = Float.parseFloat(result);
                                    } catch (NumberFormatException ignore) {
                                        // ignore
                                    }
                                    selectedWaypoint.setGeofence(newValue);
                                    saveAndNotify();
                                }
                );
                refreshOnResume = true;
            }
        } else if (itemId == R.id.menu_waypoint_visited) {
            if (selectedWaypoint != null) {
                ensureSaved();
                AndroidRxUtils.andThenOnUi(AndroidRxUtils.computationScheduler, () -> {
                    selectedWaypoint.setVisited(true);
                    saveAndNotify();
                }, this::notifyDataSetChanged);
            }
        } else if (itemId == R.id.menu_waypoint_copy_coordinates) {
            if (selectedWaypoint != null) {
                final Geopoint coordinates = selectedWaypoint.getCoords();
                if (coordinates != null) {
                    ClipboardUtils.copyToClipboard(
                            GeopointFormatter.reformatForClipboard(coordinates.toString()));
                    showToast(getString(R.string.clipboard_copy_ok));
                }
            }
        } else if (itemId == R.id.menu_waypoint_clear_coordinates) {
            if (selectedWaypoint != null) {
                ensureSaved();
                new ClearCoordinatesCommand(this, cache, selectedWaypoint).execute();
            }
        } else if (itemId == R.id.menu_waypoint_duplicate) {
            ensureSaved();
            AndroidRxUtils.andThenOnUi(AndroidRxUtils.computationScheduler, () -> {
                if (cache.duplicateWaypoint(selectedWaypoint, true) != null) {
                    saveAndNotify();
                    return true;
                }
                return false;
            }, result -> {
                if (result) {
                    notifyDataSetChanged();
                }
            });
        } else if (itemId == R.id.menu_waypoint_toclipboard) {
            if (selectedWaypoint != null) {
                ensureSaved();
                ClipboardUtils.copyToClipboard(selectedWaypoint.reformatForClipboard());
                showToast(getString(R.string.clipboard_copy_ok));
            }
        } else if (itemId == R.id.menu_waypoint_open_geochecker) {
            if (selectedWaypoint != null) {
                ensureSaved();
                final Pair<String, CheckerUtils.GeoChecker> geocheckerData = CheckerUtils.getCheckerData(cache, selectedWaypoint.getCoords());
                if (geocheckerData != null) {
                    if (!geocheckerData.second.allowsCoordinate()) {
                        final Geopoint coordinates = selectedWaypoint.getCoords();
                        if (coordinates != null) {
                            ClipboardUtils.copyToClipboard(GeopointFormatter.reformatForClipboard(coordinates.toString()));
                        }
                    }
                    ShareUtils.openUrl(this, geocheckerData.first, true);
                }
            }
        } else if (itemId == R.id.menu_waypoint_delete) {
            ensureSaved();
            final int waypointPos = WaypointsViewCreator.indexOfWaypoint(cache, selectedWaypoint);
            AndroidRxUtils.andThenOnUi(AndroidRxUtils.computationScheduler, () -> {
                if (cache.deleteWaypoint(selectedWaypoint)) {
                    saveAndNotify();
                    return true;
                }
                return false;
            }, result -> {
                if (result) {
                    if (waypointPos > 0) {
                        selectedWaypoint = WaypointsViewCreator.createSortedWaypointList(cache).get(waypointPos - 1); // set new list position to avoid jumping to the top
                    }
                    notifyDataSetChanged();
                    GeocacheChangedBroadcastReceiver.sendBroadcast(CacheDetailActivity.this, cache.getGeocode());
                }
            });
        } else if (itemId == R.id.menu_waypoint_navigate_default) {
            if (selectedWaypoint != null) {
                NavigationAppFactory.startDefaultNavigationApplication(1, this, selectedWaypoint);
            }
        } else if (itemId == R.id.menu_waypoint_navigate) {
            if (selectedWaypoint != null) {
                NavigationAppFactory.showNavigationMenu(this, null, selectedWaypoint, null);
            }
        } else if (itemId == R.id.menu_waypoint_caches_around) {
            if (selectedWaypoint != null) {
                final Geopoint coordinates = selectedWaypoint.getCoords();
                if (coordinates != null) {
                    CacheListActivity.startActivityCoordinates(this, coordinates, selectedWaypoint.getName());
                }
            }
        } else if (itemId == R.id.menu_waypoint_reset_cache_coords) {
            ensureSaved();
            if (ConnectorFactory.getConnector(cache).supportsOwnCoordinates()) {
                createResetCacheCoordinatesDialog(selectedWaypoint).show();
            } else {
                final HandlerResetCoordinates handler = new HandlerResetCoordinates(this, false);
                handler.showProgress();
                resetCoords(cache, handler, selectedWaypoint, true, false);
            }
        } else if (itemId == R.id.menu_calendar) {
            CalendarAdder.addToCalendar(this, cache);
        }
        return true;
    }
waypoint selected in context menu. This variable will be gone when the waypoint context menu is a fragment.
main/src/main/java/cgeo/geocaching/CacheDetailActivity.java