I have an EditText that I manually control showing keyboard by below code:
private void showKeyboard(boolean show) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (show) {
mAddNewEditText.requestFocus();
imm.showSoftInput(mAddNewEditText, 0);
} else {
mAddNewEditText.clearFocus();
imm.hideSoftInputFromWindow(mAddNewEditText.getWindowToken(), 0);
}
}
I'll call implicit intent to gets a new image and when it goes back to activity, it wont show the soft keyboard. So I tried to show the keyboard onResume function as below:
@Override
protected void onResume() {
super.onResume();
if (mAddNewEditText.isFocused()) {
mAddNewEditText.post(
() -> showKeyboard(true)
);
}
}
but it shows the keyboard like this which is different than normally showing the keyboard:
I'm wondering what is the problem here. Is it because I'm using post method? without post I cannot show keyboard!
What have I tried:
Note: I'm using Android emulator.
Okay I found the answer: in my styles.xml I had this code :
<item name="android:windowFullscreen">true</item>
which caused the problem, not sure why.