'How can I answer to callback in Java telegram bot?

I'm writing a Java bot with https://github.com/rubenlagus/TelegramBots, and I have a problem, when I click inline keyboard button, this little clock:
clock appears and after some time it says that my bot is not responding. My bot is actually fully functional except this one thing. Here is how I receive callbacks:

@Override
public void onUpdateReceived(Update update) {
    var messagesToSend = updateReceiver.handle(update);

    if (messagesToSend != null && !messagesToSend.isEmpty()) {

        messagesToSend.forEach(response -> {
            if (response instanceof SendMessage) {
                try {
                    execute((SendMessage) response);
                } catch (TelegramApiException e) {
                    e.printStackTrace();
                }
            } else if (response instanceof SendPhoto) {
                try {
                    execute((SendPhoto) response);
                } catch (TelegramApiException e) {
                    e.printStackTrace();
                }
            } else if (response instanceof FileSaveRequest) {
                FileSaveRequest request = (FileSaveRequest) response;
                try {
                    saveFile(request);
                } catch (TelegramApiException | IOException e) {
                    e.printStackTrace();
                }
            }
        });
    }

}

= This is only part of the whole code

 } else if (update.hasCallbackQuery()) {
            final CallbackQuery callbackQuery = update.getCallbackQuery();
            final long chatId = callbackQuery.getFrom().getId();
            final User user = userRepository.findById(chatId)
                    .orElseGet(() -> userRepository.save(new User(chatId)));

            AnswerCallbackQuery acceptCallback = new AnswerCallbackQuery();
            acceptCallback.setShowAlert(false);
            acceptCallback.setCallbackQueryId(String.valueOf(update.getCallbackQuery().getId()));
            acceptCallback.setCacheTime(1000);
            List<PartialBotApiMethod<? extends Serializable>> resultList =
                    new ArrayList<>(
                            getHandlerByCallBackQuery(callbackQuery.getData())
                            .handle(user, callbackQuery.getData()));
            resultList.add(acceptCallback);
            return resultList;
        }

As you can see, I still attach AnswerCallbackQuery but it still doesent work. What's wrong?



Solution 1:[1]

you must use answercallbackquery

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ali Razavian