content: package cn.hotapk.fastandrutils.utils;
  
  import android.app.Activity;
  import android.content.Context;
  import android.view.View;
  import android.view.inputmethod.InputMethodManager;
  import android.widget.EditText;
  
  import static android.content.Context.INPUT_METHOD_SERVICE;
  
  /**
   * @author laijian
   * @version 2017/8/29
   * @Copyright (C)下午2:55 , Suntektech
   * 键盘类
   */
  public class FKeyBoardUtils {
      /**
       * 打开软键盘
       * 魅族可能会有问题
       *
       * @param mEditText
       * @param mContext
       */
      public static void openKeybord(EditText mEditText, Context mContext) {
          InputMethodManager imm = (InputMethodManager) mContext
                  .getSystemService(INPUT_METHOD_SERVICE);
          imm.showSoftInput(mEditText, InputMethodManager.RESULT_SHOWN);
          imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
                  InputMethodManager.HIDE_IMPLICIT_ONLY);
      }
  
      /**
       * 关闭软键盘
       *
       * @param mEditText
       * @param mContext
       */
      public static void closeKeybord(EditText mEditText, Context mContext) {
          InputMethodManager imm = (InputMethodManager) mContext.getSystemService(INPUT_METHOD_SERVICE);
          imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
      }
  
  
      /**
       * des:隐藏软键盘,这种方式参数为activity
       *
       * @param activity
       */
      public static void hideInputForce(Activity activity) {
          if (activity == null || activity.getCurrentFocus() == null)
              return;
          ((InputMethodManager) activity.getSystemService(INPUT_METHOD_SERVICE))
                  .hideSoftInputFromWindow(activity.getCurrentFocus()
                          .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
      }
  
      /**
       * 打开键盘
       **/
      public static void showInput(Context context, View view) {
          InputMethodManager imm = (InputMethodManager) context.getSystemService(INPUT_METHOD_SERVICE);
          if (imm != null) {
              view.requestFocus();
              imm.showSoftInput(view, 0);
          }
      }
  
  
  }
  