public static boolean isKeyboardVisible ( Activity activity ) { Rect r = new Rect ( ) ; View activityRoot = getActivityRoot ( activity ) ; activityRoot . getWindowVisibleDisplayFrame ( r ) ; int screenHeight = activityRoot . getRootView ( ) . getHeight ( ) ; int heightDiff = screenHeight - r . height ( ) ; return heightDiff > screenHeight * KEYBOARD_MIN_HEIGHT_RATIO ; }
Determine if keyboard is visible