Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Activity activity = getActivity();
- InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
- try
- {
- inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
- }
- catch (Exception e)
- {
- }
- InputMethodManager imm = (InputMethodManager)this.getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0);
- class MyFrag extends Fragment{
- @Override
- public void onConfigurationChanged(Configuration config){
- //Check flags
- switch(config.keyboardHidden){
- case KEYBOARDHIDDEN_NO:
- // do something
- break;
- case KEYBOARDHIDDEN_YES:
- break;
- }
- }
- }
- <activity ...
- android:configChanges="keyboardHidden|orientation|screenSize|screenLayout"/>
- Configuration config = getResources().getConfiguration();
- @Override
- protected void onPause() {
- super.onPause();
- final InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
- if (inputMethodManager != null && inputMethodManager.isActive()) {
- if (getCurrentFocus() != null) {
- inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement