Android Ime callback not found issue on AlertDialog dismiss

910 Views Asked by At

If we have a customized AlertDialog containing some input field, selection of that component would prompt the IME virtual keyboard of the device to pop up. Now, if we dismiss the entire AlertDialog by simply clicking anywhere outside of its bounds (NOT by pressing the back navigation key/ gesture), LogCat logs the following error:

Ime callback not found. Ignoring unregisterReceivedCallback.

This seemingly doesn't affect anything, since it's just ignored a mentioned by the log message, but I'm not sure of it and would rather it not appear. But I'm unable to find a way to attach a callback method for the IME on the component. To be exact, I am unable to identify the actual method to override or set and whether to do this on the Component level, ActivityLevel, or on the InputMethodManager instance itself.

Some searches on this indicated I might have to do something at OnBackPressedDispatcher but I could not find exactly what to do there.

Most searches also yield Kotlin code, which is interesting because the callback pattern has mostly been used in Kotlin coded apps. So perhaps this is a Kotlin specific thing, much like coroutines?

I've also tried attaching an OnEditorActionListener to my component to no avail

.setOnEditorActionListener(new TextView.OnEditorActionListener()
{
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
    {
        if(actionId == EditorInfo.SOME_CODE)
        {
            return true;
        }
        return false;
    }
});

I've tried setting a custom OnDismissListener on my custom AlertDialog without results. The thing is, we cannot solve it without first knowing what to solve. On that aspect, I found some code relating to unregisterReceivedCallback here. However, the class containing the method (ImeOnBackInvokedDispatcher) is not extended by any of the classes involved in my issue that I can identify - not the AlertDialog, not the EditText, not Activity, nor InputMethodManager.

Most likely, the method is abstract and has to be made concrete at getOnBackPressedDispatcher().addCallback(... (as the code in the above link implements the OnBackInvokedDispatcher interface class) but so far I'm unable to figure out how to move forward.

Any advice is much appreciated.

0

There are 0 best solutions below