title: Application sometimes crashes after language resource change
body: <p>Problem: application crashes with <code>StackOverflowError</code></p>
  
  <pre><code>ViewRoot.draw(boolean) line: 1374   
  ViewRoot.performTraversals() line: 1114 
  ViewRoot.handleMessage(Message) line: 1633  
  ViewRoot(Handler).dispatchMessage(Message) line: 99 
  Looper.loop() line: 123 
  </code></pre>
  
  <p>I have a <code>TabActivity</code> with some tabs. I add tabs like this: </p>
  
  <pre><code>intent = new Intent().setClass(this, SigninActivity.class);
  spec = tabHost.newTabSpec("Signin").setIndicator("CV", res.getDrawable(R.drawable.ic_tab_signin)).setContent(intent);
  tabHost.addTab(spec);
  </code></pre>
  
  <p>In the tab I have, on click I show a pop-up with two buttons from <a href="https://stackoverflow.com/questions/3121232/android-popup-window-dismissal">Android popup window dismissal</a> 
  When clicking on some button in popup, language changes like this:</p>
  
  <pre><code>Locale mLocale = new Locale("ar");
  Locale.setDefault(mLocale);
  Configuration config = getBaseContext().getResources().getConfiguration();
  if (!config.locale.equals(mLocale)) {
      config.locale = mLocale;
      getBaseContext().getResources().updateConfiguration(config, null);
      replaceContentView("Signin", new Intent(NewAccActivity.this, NewAccActivity.class));
  }
  </code></pre>
  
  <p>And when I click 6-7 times in one tab to change the language (layout and values), the application crashes with a <code>NullPointer</code> on method <code>(PopupWindow)this.window.dismiss()</code> in popup. </p>
  
  <p>I added a timer for calling <code>dismiss()</code>, but now application crashes with <code>StackOverflowError</code> after 6-7 language changes. </p>
  
  <p>Where is the problem?</p>
  
  <p><strong>Upd:</strong> I remove timer. In popup screen all buttons have one <code>OnClickListener</code>. </p>
  
  <p>In activity:</p>
  
  <pre><code>    Button btnDialogShow = (Button) findViewById(R.id.button);
      btnDialogShow.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
              dw = new LanguageChangeDialog(v, getBaseContext());
              dw.setOnClickListener(new OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      Button b = (Button) v;
                      switch (b.getId()) {
                      case R.id.en:
                          cvitchToEn();
                          break;
                      case R.id.ar:
                          cvitchToAr();
                          break;
                      }
                  }
              });
              dw.showLikePopDownMenu();
          }
      });
  </code></pre>
  
  <p>If it looks like this, were this.onClickListener external ClickListener in Activity, witch change locale:</p>
  
  <pre><code>public void setOnClickListener(OnClickListener onClickListener) {
      this.onClickListener = onClickListener;
  }
  
  public void onClick(final View v) {
      onClickListener.onClick(v);
      dismiss();
  }
  </code></pre>
  
  <p>After click I have exception:</p>
  
  <pre><code>Thread [&lt;3&gt; main] (Suspended (exception NullPointerException))  
      PopupWindow$1.onScrollChanged() line: 124   
      ViewTreeObserver.dispatchOnScrollChanged() line: 607    
      ViewRoot.draw(boolean) line: 1195   
      ViewRoot.performTraversals() line: 1114 
      ViewRoot.handleMessage(Message) line: 1633  
      ViewRoot(Handler).dispatchMessage(Message) line: 99 
      Looper.loop() line: 123 
  </code></pre>
  
  <p>If I change onClick (another order) like:</p>
  
  <pre><code>public void onClick(final View v) {
      dismiss();
      onClickListener.onClick(v);
  }
  </code></pre>
  
  <p>It works, but after 6-7 click, i have:</p>
  
  <pre><code>Thread [&lt;3&gt; main] (Suspended (exception StackOverflowError))    
      ViewRoot.draw(boolean) line: 1374   
      ViewRoot.performTraversals() line: 1114 
      ViewRoot.handleMessage(Message) line: 1633  
      ViewRoot(Handler).dispatchMessage(Message) line: 99 
      Looper.loop() line: 123 
  </code></pre>
  
  <p>Bug here somewhere, but I can not understand where.</p>