You are dismissing your dialog from the background thread - you can't do this. Specifically you can't do any UI operations from a background thread.
Have a look at AsyncTask in the SDK it should do everything you need. Hint dismiss your dialog in onPostExecute. On Jul 11, 8:22 am, "pramod.deore" <[email protected]> wrote: > I have developed simple application of progress bar in that when I hit > the button then it will do some work in background and one progress > bar is visible on foreground. afte completing back ground work it > display the same screen. It works fine if I don't rotate mobile but > when I rotate mobile then it throws > java.lang.IllegalArgumentException: View not attached to window > manager > > I know when we rotate the device or open keypad it starts activity > restarted. But How to avoid this error. > My code is > > public class TestProgressBar extends Activity implements > OnClickListener > { > /** Called when the activity is first created. */ > > Button hitMe; > boolean test; > Handler mHandler = new Handler(); > ProgressDialog myProgressDialog = null; > public void onCreate(Bundle savedInstanceState) > { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > System.out.println ("Before setContentView"); > hitMe = (Button)findViewById(R.id.widget30); > System.out.println ("Before rsgistering with listener"); > > hitMe.setOnClickListener(this); > System.out.println ("after rsgistering with listener"); > > } > > public void onClick(View v) > { > if (v==hitMe) > { > final ProgressDialog myProgressDialog ; > myProgressDialog = ProgressDialog.show(this, "Please wait...", > "Doing Extreme Calculations...", true); > new Thread() > { > > public void run() { > try{ > // Do some Fake-Work > for (int i=00;i<100000;i++) > { > System.out.println > ("****************"); > } > System.out.println ("Outside > for loop"); > } catch (Exception e) { } > // Dismiss the Dialog > //setContentView(R.layout.main1); > myProgressDialog.dismiss(); > > } > > }.start(); > > } > > } > > } > > Please help me. Thanks in advance -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

