"KeyEvent can't be processed because this key input node is not active."
Is there any information on what i'm doing wrong and how to fix this?
After a briefly looking into compose source code I was not able to find any handle to prevent this crash, so I'm just suppressing the crash on activity level inside of
dispatchKeyEvent
method, is there a better workaround for the issue? (compose 1.0.0-alpha07)
d
Denis Sakhapov
11/15/2020, 2:08 PM
Hi!
Could you please share how you suppress the crash on activity level? I’ve been having the same issue and haven’t found a solution yet either. Same thing happens when we use a
WebView
inside an
AndroidView
p
Pavel Marchenko
11/15/2020, 2:14 PM
Sure, please see below:
Copy code
override fun dispatchKeyEvent(event: KeyEvent?): Boolean {
return try {
super.dispatchKeyEvent(event)
} catch (e: IllegalStateException) {
if (event?.keyCode == KeyEvent.KEYCODE_BACK) {
onBackPressedDispatcher.onBackPressed()
true
} else {
throw e
}
}
}
at the first look this was enough to workaround my case, however, I haven't tested if it covers all the cases yet
❤️ 1
d
Denis Sakhapov
11/15/2020, 2:23 PM
Thanks. Will give this a try. Appreciate the help!