Background task, progress dialog, orientation change - is there any 100% working solution?
<p>I download some data from internet in background thread (I use <code>AsyncTask</code>) and display a progress dialog while downlaoding. Orientation changes, Activity is restarted and then my AsyncTask is completed - I want to dismiss the progess dialog and start a new Activity. But calling dismissDialog sometimes throws an exception (probably because the Activity was destroyed and new Activity hasn't been started yet).</p>

<p>What is the best way to handle this kind of problem (updating UI from background thread that works even if user changes orientation)? Did someone from Google provide some "official solution"?</p>
