public static void hide(@NonNull final Activity activity) {
        // Check if no view has focus:
        final View view = activity.getCurrentFocus();
        if (view != null) {
            final InputMethodManager inputManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
            inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }
Class for hiding/showing the soft keyboard on Android.
main/src/main/java/cgeo/geocaching/activity/Keyboard.java