Use the InputMethodManager.hideSoftInputFromWindow()
This method is mentioned frequently on the internet such as on this stackoverflow post here:
You can think of the InputMethodManager as a system service that mediates between your application and any input method you might be trying to use (in this case the keyboard).