In my Activity I have an AutoCompleteTextView with a dropdown list. When the user selects an item, a new Activity is started. Since I have a lot of stuff in the next Activity, there's a delay of about 0.5-1s before it starts. I'm trying to hide the soft keyboard immediately after an item is selected:
actvActionSearch.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapter, View v,
int position, long id) {
imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(actvActionSearch.getWindowToken(), 0);
//do stuff to prepare and start next Activity
}
});
However, the soft keyboard gets hidden appr. at the same time the next Activity starts. Where does this delay come from? Hiding the keyboard is the 1st thing I perform
Note how you are getting
InputMethodManageras a system service?That means your call to
hideSoftInputFromWindowis performed on a systemService, which means its always running in the background along side of your app, which means when you hide keyboard, its actually running in parallel as your app which is performing the activity create.