title: SurfaceView inside TabHost causes crash
body: <p>I have a SurfaceView-derived class in an Activity inside a TabHost (like the HelloTabWidget sample). The SurfaceView I'm using comes with the excellent andrtoid-flot-chart library: <a href="http://code.google.com/p/flot-android-chart/source/browse/branches/flot_android1.0/src/com/flotandroidchart/flot/FlotChartContainer.java" rel="nofollow">FlotChartContainer.java</a></p>
  
  <p>When I switch between the tabs, everything works. However, as soon as the tab containing this view has been initialized (e.g. shown) my application is doomed. It will crash whenever the following occurs:</p>
  
  <p><strong>Pressing Home button</strong>
  When I re-open my application, it crashes due to an <em>IllegalStateException</em> in surfaceCreated().</p>
  
  <p><strong>Starting new activity</strong>
  When I start a new activity (<em>startActivity</em>) and press the Back button (this invokes my SurfaceView's <em>surfaceDestroyed</em>...?!), it crashes due to an <em>IllegalStateException</em> in surfaceCreated().</p>
  
  <ul>
  <li>I'm targeting API level 7 (Android 2.1).</li>
  <li>The code works when TabHost is not used.</li>
  <li>Switching between tabs does not invoke surfaceDestroyed(). Instead, onPause() and onResume() are used.</li>
  <li>When an activity is finished, surfaceDestroyed() is called even if it is not in the active tab.</li>
  </ul>
  
  <p>Please help!</p>