// Import the necessary classes
import android.content.Context
import android.view.inputmethod.InputMethodManager
import android.app.Activity
// Function to hide the keyboard
fun hideKeyboard(activity: Activity) {
val inputMethodManager =
activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
val currentFocusView = activity.currentFocus
if (currentFocusView != null) {
inputMethodManager.hideSoftInputFromWindow(
currentFocusView.windowToken, InputMethodManager.HIDE_NOT_ALWAYS
)
}
}