1

I am trying to detect whether the keyboard is visible or not. The standard way of detecting the keyboard in mobile does not work in Android TV.

Any suggestions?

sadat
  • 4,004
  • 2
  • 29
  • 49
  • The "new" standard way is this: https://stackoverflow.com/a/68380870/2910520, have you already tried this? (just asking) – MatPag Aug 24 '21 at 08:25

2 Answers2

0

May I ask why you want to know the keyboard status?

If i had no other way i would:-

  1. When you want the keyboard open ... force close and open and vice versa
  2. Create a global boolean flag that would change depending on whether a textfield is clicked .. if clicked, boolean = true ... if keyboard opened(blooean = true), and back button pressed then set boolean = false ...
0

What I was looking for something like this

fun isKeyBoardVisible() = ViewCompat.getRootWindowInsets(requireView())?.isVisible(WindowInsetsCompat.Type.ime()) ?: false
sadat
  • 4,004
  • 2
  • 29
  • 49