Question

I know that to hide soft keyboard I need to use code like this:

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);

My problem is that I starting the ACTION_SEND intent, and use Twitter app to handle it. I pass a message to tweet it. But if the user does not confirm the message, but clicks ActionBar back button, the Twitter activity is finished, and my app lication comes back to the front. But the soft Keyboard, called by Twitter does not hide. I have no idea how to get Twitter's WindowToken. Could anybody help me?

Was it helpful?

Solution 2

I have found an unswer. I had to add this code:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

in the onResume() method

OTHER TIPS

Another way is to do the same in AndroidManifest.xml file. You can annotate your activity with the following line:

android:windowSoftInputMode="stateAlwaysHidden"

which means your activity will always hide keyboard when receives focus.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top