explanation about activity re-creation on configuration change and context
<p>I'm pretty new to Android development and I'm looking for explanation about a problem I'm facing, for gaining deeper understanding of Android.</p>

<p>I have this piece of code:</p>

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

<p>if the dropdown list is visible and the configuration changes (screen orientation) I'm getting a BadTokenException.</p>

<p>I understand that the activity is destroyed and a new one is created to replace it, but I don't quite understand what's really going on and why am I getting that exception,
after all, a new activity is created with new listeners registered to the new views and the old ones are destroyed.</p>

<p>I know that I can fix this by telling the manifest that I'll be handling configuration changes by myself, but I'm looking into deeper understanding.</p>

<p>thanks!</p>
