Progress dialog problem in Android
<p>I want to create a simple <code>ProgressDialog</code> in my Activity. I created it like this:</p>

<pre><code>protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.channellist);

    final Context c=this;

    t1=(TextView) findViewById(R.id.channellistStatus);

    listView=(ListView) findViewById(R.id.channellist);

    rc=RCManager.getInstance();

    chlistAdapter = new ChannelListAdapter(this,R.layout.channellist_row_lyt,clist);

    listView.setAdapter(chlistAdapter);

    t1.setText("No Channel List Found...");

    progDailog=ProgressDialog.show(this,"HI", "Loading");

    new Thread(new Runnable() {

        @Override
        public void run() {
            try 
            {
                Thread.sleep(3000);
            } 
            catch (InterruptedException e) 
            {
                e.printStackTrace();
            }   
            updateChannelList();
        }
    }).start();
</code></pre>

<p>But it is resulting in the following Exception ie <strong>WindowManager BadToken Exception</strong>. I don't know why it is. Please can anyone help me to solve this?</p>

<pre><code>05-23 16:56:44.573: ERROR/AndroidRuntime(2494): FATAL EXCEPTION: main
05-23 16:56:44.573: ERROR/AndroidRuntime(2494): java.lang.RuntimeException: Unable            to start activity           ComponentInfo{com.nds.fr.activities/com.nds.fr.activities.TabGroup2Activity}:  java.lang.RuntimeException: Unable to start activity   ComponentInfo{com.nds.fr.activities/com.nds.fr.activities.ChannelListing}:  android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@48189240 is not valid; is your activity running?
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:651)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.widget.TabHost.setCurrentTab(TabHost.java:323)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:129)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:453)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.view.View.performClick(View.java:2408)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.view.View$PerformClick.run(View.java:8818)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.os.Handler.handleCallback(Handler.java:587)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.os.Handler.dispatchMessage(Handler.java:92)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.os.Looper.loop(Looper.java:123)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.ActivityThread.main(ActivityThread.java:4627)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at java.lang.reflect.Method.invokeNative(Native Method)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at java.lang.reflect.Method.invoke(Method.java:521)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at dalvik.system.NativeStart.main(Native Method)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nds.fr.activities/com.nds.fr.activities.ChannelListing}: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@48189240 is not valid; is your activity running?
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at com.nds.fr.activities.TabGroupActivity.startChildActivity(TabGroupActivity.java:65)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at com.nds.fr.activities.TabGroup2Activity.onCreate(TabGroup2Activity.java:10)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     ... 18 more
05-23 16:56:44.573: ERROR/AndroidRuntime(2494): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@48189240 is not valid; is your activity running?
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.view.ViewRoot.setView(ViewRoot.java:505)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:200)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:114)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.Dialog.show(Dialog.java:241)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.ProgressDialog.show(ProgressDialog.java:107)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.ProgressDialog.show(ProgressDialog.java:90)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.ProgressDialog.show(ProgressDialog.java:85)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at com.nds.fr.activities.ChannelListing.onCreate(ChannelListing.java:65)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-23 16:56:44.573: ERROR/AndroidRuntime(2494):     ... 25 more
</code></pre>
