FrostCodes Active Member Licensed User Longtime User Jun 13, 2022 #1 Hello everyone, I tried to use the IME_HeightChanged(NewHeight As Int, OldHeight As Int) event to hide my AdMob banner when the user is typing but I am unable to use this to know if the keyboard was closed back. I need a way to know if the keyboard is opened/closed.
Hello everyone, I tried to use the IME_HeightChanged(NewHeight As Int, OldHeight As Int) event to hide my AdMob banner when the user is typing but I am unable to use this to know if the keyboard was closed back. I need a way to know if the keyboard is opened/closed.
agraham Expert Licensed User Longtime User Jun 13, 2022 #2 Android IME was handling has always been rubbish, though I think Android 11 or 12 improved things a bit with an imnproved API but that doesn't really help until (if ever) most devices out there are updated. See if GetKeyboardRectangle in my IME2 library does what you want. IME2 Library I have been having a lot of trouble lately with layouts being corrupted when rotating a device with the soft keyboard open. The problem stems from trying to use the IME library HeightChanged event. Unfortunately Android provides no direct way to determine whether the soft keyboard is shown or... www.b4x.com Upvote 0
Android IME was handling has always been rubbish, though I think Android 11 or 12 improved things a bit with an imnproved API but that doesn't really help until (if ever) most devices out there are updated. See if GetKeyboardRectangle in my IME2 library does what you want. IME2 Library I have been having a lot of trouble lately with layouts being corrupted when rotating a device with the soft keyboard open. The problem stems from trying to use the IME library HeightChanged event. Unfortunately Android provides no direct way to determine whether the soft keyboard is shown or... www.b4x.com
Erel B4X founder Staff member Licensed User Longtime User Jun 14, 2022 #3 FrostCodes said: Hello everyone, I tried to use the IME_HeightChanged(NewHeight As Int, OldHeight As Int) event to hide my AdMob banner when the user is typing but I am unable to use this to know if the keyboard was closed back. Click to expand... You can compare NewHeight to the activity / root height. Upvote 0
FrostCodes said: Hello everyone, I tried to use the IME_HeightChanged(NewHeight As Int, OldHeight As Int) event to hide my AdMob banner when the user is typing but I am unable to use this to know if the keyboard was closed back. Click to expand... You can compare NewHeight to the activity / root height.
FrostCodes Active Member Licensed User Longtime User Jun 14, 2022 #4 Thank @agraham, truly an android engineering mess at its best lol! I tried both your code and @Erel code/suggestion and they both work. I appreciate. Upvote 0
Thank @agraham, truly an android engineering mess at its best lol! I tried both your code and @Erel code/suggestion and they both work. I appreciate.
FrostCodes Active Member Licensed User Longtime User Jun 14, 2022 #5 My Final Code: B4X: Copy Sub Globals Private ActivityHeight As Int = 0 End Sub Code: Copy Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("Layout1") ActivityHeight = Activity.Height End Sub Code: Copy Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int) Private IsIMEKeyboardClosed As Boolean = (NewHeight = ActivityHeight) LogColor("IsIMEKeyboardClosed >> " & IsIMEKeyboardClosed, Colors.Red) End Sub Upvote 0
My Final Code: B4X: Copy Sub Globals Private ActivityHeight As Int = 0 End Sub Code: Copy Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("Layout1") ActivityHeight = Activity.Height End Sub Code: Copy Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int) Private IsIMEKeyboardClosed As Boolean = (NewHeight = ActivityHeight) LogColor("IsIMEKeyboardClosed >> " & IsIMEKeyboardClosed, Colors.Red) End Sub