Now, I try to hide the softkeyboard when user touch outside the keyboard:
((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(editView.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
I want put the logic in my base activity class, so if it is possible to getWindowToken without View?
I faced exactly the same problem, while writing OnPageChangeListener
within an Activity. You can use one of these solutions. Either:
getWindow().getDecorView().getRootView().getWindowToken()
or:
findViewById(android.R.id.content).getWindowToken()
Surely you can use:
getContentView().getWindowToken()
or you can refer to SO Quest
Simply use getWindow().getDecorView().getWindowToken()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With