title: Dismiss dialogue after configuration is changed
body: <p>I'm currently writing on a Bluetooth application only allowing the user to work with it in the portait mode. However, there are some other reasons causing confguration changes forcing me to show the user that the Bluetooth connection has been lost.</p>
  
  <p>While connecting to a device I show a dialogue prompting a password. If a configuration change occurs while this dialogue is visible I want to dismiss it. Therefore I call a helper method in <code>onSaveInstanceState</code>, <code>onDestroy</code> as well as <code>onCreate</code> (if the saved instance state is not null).</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState)
  {
      if (savedInstanceState != null)
      {
          this.tryDismiss();
      }
      super.onCreate(savedInstanceState);
  }
  
  @Override
  public void onSaveInstanceState(Bundle outState)
  {
      System.out.println("Saving instance state!");
      this.tryDismiss();
  
      super.onSaveInstanceState(outState);
  }
  
  @Override
  public void onDestroy()
  {
      System.out.println("Destroying dialogue!");
      this.tryDismiss();
  
      super.onDestroy();
  }
  
  public void tryDismiss()
  {
      try
      {
          System.out.println("DIE BART, DIE!");
          this.dismissAllowingStateLoss();
      }
      catch (Exception closingException)
      {
      }
  }
  </code></pre>
  
  <p>However, the dialogue is still displayed to the user. I have read a similar questions, but couldn't figure out a solution to this issue.</p>
  
  <p>I appreciate any help. Thanks in advance!</p>