質問

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?

役に立ちましたか?

解決 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

他のヒント

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top