public static boolean onMenuItemSelected(final MenuItem item, @NonNull final CacheMenuHandler.ActivityInterface activityInterface, @Nullable final Geocache cache, @Nullable final Runnable notifyDataSetChanged, final boolean fromPopup) {
        final Activity activity;
        if (activityInterface instanceof Activity) {
            activity = (Activity) activityInterface;
        } else {
            activity = ((Fragment) activityInterface).getActivity();
        }

        final int menuItem = item.getItemId();
        if (menuItem == R.id.menu_default_navigation) {
            activityInterface.navigateTo();
            return true;
        } else if (menuItem == R.id.menu_navigate) {
            final NavigationSelectionActionProvider navigationProvider = (NavigationSelectionActionProvider) MenuItemCompat.getActionProvider(item);
            if (navigationProvider == null || fromPopup) {
                activityInterface.showNavigationMenu();
                return true;
            }
            return false;
        } else if (menuItem == R.id.menu_caches_around || menuItem == R.id.menu_caches_around_from_popup) {
            activityInterface.cachesAround();
            return true;
        } else if (menuItem == R.id.menu_upload_bookmarklist) {
            BookmarkUtils.askAndUploadCachesToBookmarkList(activity, Collections.singletonList(cache));
            return true;
        } else if (menuItem == R.id.menu_show_in_browser) {
            if (cache != null) {
                ShareUtils.openUrl(activity, cache.getUrl(), true);
            }
            return true;
        } else if (menuItem == R.id.menu_log_in_browser) {
            if (cache != null) {
                ShareUtils.openUrl(activity, cache.getCreateNewLogUrl(), true);
            }
            return true;
        } else if (menuItem == R.id.menu_share || menuItem == R.id.menu_share_from_popup) {
            if (cache != null && activity != null) {
                ShareUtils.shareLink(activity, cache.getShareSubject(), cache.getUrl());
            }
            return true;
        } else if (menuItem == R.id.menu_share_with_data) {
            if (cache != null && activity != null) {
                final StringBuilder shareText = new StringBuilder().append(cache.getShareSubject()).append("\n").append(cache.getUrl()).append("\n\n");
                final int shareCoordText;
                final Geopoint shareCoords;
                if (cache.hasUserModifiedCoords()) {
                    shareCoordText = R.string.export_modifiedcoords;
                    shareCoords = cache.getCoords();
                } else if (cache.hasFinalDefined()) {
                    shareCoordText = R.string.wp_final;
                    shareCoords = cache.getFirstMatchingWaypoint(Waypoint::isFinalWithCoords).getCoords();
                } else {
                    shareCoordText = R.string.cache_coordinates_original;
                    shareCoords = cache.getCoords();
                }
                shareText.append(activity.getString(shareCoordText)).append(": ").append(GeopointFormatter.format(GeopointFormatter.Format.LAT_LON_DECMINUTE, shareCoords));
                if (null != cache.getPersonalNote()) {
                    shareText.append("\n").append(activity.getString(R.string.cache_personal_note)).append(": ").append(cache.getPersonalNote());
                }
                ShareUtils.sharePlainText(activity, shareText.toString());
            }
            return true;
        } else if (menuItem == R.id.menu_calendar) {
            if (cache != null && activity != null) {
                CalendarAdder.addToCalendar(activity, cache);
            }
            return true;
        } else if (menuItem == R.id.menu_set_found) {
            if (cache != null) {
                setFoundState(activity, cache, true, false, notifyDataSetChanged);
            }
        } else if (menuItem == R.id.menu_set_DNF) {
            if (cache != null) {
                setFoundState(activity, cache, false, true, notifyDataSetChanged);
            }
        } else if (menuItem == R.id.menu_reset_foundstate && cache != null) {
            setFoundState(activity, cache, false, false, notifyDataSetChanged);
        }
        return false;
    }
Methods to be implemented by the activity to react to the cache menu selections.
main/src/main/java/cgeo/geocaching/CacheMenuHandler.java