title: Hiding keyboard - getCurrentFocus() return null
body: <p>I want to implement generic method to hide keyboard from any activity. My code:</p>
  
  <pre><code>public static void hide(Activity activity) {
      if (null == activity) {
          return;
      }
  
      View view = activity.getCurrentFocus();
      if (null == view) {
          return;
      }
  
      InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
      inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
  }
  </code></pre>
  
  <p>It works well for most of my activities but not for all of them. The problem is that sometimes getCurrentFocus() return null even when selected editText is focused. What can be wrong with this activity? Why this method return null?</p>