BadTokenException at AutoCompleteTextView showDropDown() inside a listener
<p>I have two activities, activity1 is starting activity2.
in activity 2 I registered an OnFocusChangeListener to a AutoCompleteTextView:</p>

<pre><code>someTextView.setOnFocusChangeListener(new OnFocusChangeListener() {
    @Override
    public void onFocusChange(View v, boolean hasFocus) {
    if (hasFocus)
    ((AutoCompleteTextView)v).showDropDown();
    else
    ((AutoCompleteTextView)v).dismissDropDown();
}       
});
</code></pre>

<p>if i write something in the textview and then the activity configuration changes (screen rotate) I get the WindowManager.BadTokenException.
I isolated this to the showDropDown and dismissDropdown methods (by commenting them).
I also tried executing those two methods directly on the Activity's View object (instead of the one passed through the listener) and got the same exception.</p>

<p>what am I doing wrong ?</p>
