InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
Some other methods:
http://stackoverflow.com/questions/1109022/close-hide-the-android-soft-keyboard