Force hide keyboard will changing fragment

This commit is contained in:
Sylvain Berfini 2018-09-10 17:32:36 +02:00
parent f2bfc33bcd
commit d734e93ed2
2 changed files with 11 additions and 0 deletions

View file

@ -40,6 +40,7 @@ import android.text.Spanned;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
@ -761,5 +762,14 @@ public final class LinphoneUtils {
public static String getStorageDirectory(Context mContext) {
return Environment.getExternalStorageDirectory() + "/" + mContext.getString(mContext.getResources().getIdentifier("app_name", "string", mContext.getPackageName()));
}
public static void hideKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
View view = activity.getCurrentFocus();
if (view == null) {
view = new View(activity);
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}

View file

@ -455,6 +455,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
} else {
changeFragment(fragment, newFragmentType, withoutAnimation);
}
LinphoneUtils.hideKeyboard(this);
}
}