title: ProgressDialog crash in onPreExecute() method
body: <p>The ProgressDialog is crashing in onPreExecute() method.</p>
  
  <p>Below is my code snippet:</p>
  
  <pre><code>        public class TestCasesActivity extends Activity {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_testcases);
  
                  xmlHelp = new XmlHelper();
  
                  ConfigParser confParser = new ConfigParser();
                  confParser.execute();
              }
  
              private class ConfigParser extends AsyncTask&lt;Void, Void, Void&gt; {
                  private ProgressDialog dialog;
  
              @Override
              protected void onPreExecute() {
                  dialog = new ProgressDialog(TestCasesActivity.this);
                  dialog.setMessage("Loading TestCases Configuration...");
                  dialog.show();
              }
  
          @Override
          protected Void doInBackground(Void... params) {
              xmlHelp.getNumberOfNodes();
              return null;
          }
  
          @Override
          protected void onPostExecute(Void v) {
              dialog.dismiss();
              // Show test cases list here via a ListView
          }
  }
  </code></pre>
  
  <p>Please suggest what can be wrong here.
  The logcat prints are given below:</p>
  
  <blockquote>
    <p>07-30 08:13:50.511  20200-20200/? E/WindowManager﹕
    android.view.WindowLeaked: Activity
    com.TestCasesActivity
    has leaked window
    com.android.internal.policy.impl.PhoneWindow$DecorView{31a83555
    V.E..... R......D 0,0-1026,348} that was originally added here
                at android.view.ViewRootImpl.(ViewRootImpl.java:363)
                at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:262)
                at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
                at android.app.Dialog.show(Dialog.java:298)
                at com.TestCasesActivity$ConfigParser.onPreExecute(TestCasesActivity.java:41)
                at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:587)
                at android.os.AsyncTask.execute(AsyncTask.java:535)
                at com.TestCasesActivity.onCreate(TestCasesActivity.java:30)
                at android.app.Activity.performCreate(Activity.java:5984)
                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2254)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2361)
                at android.app.ActivityThread.access$800(ActivityThread.java:147)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
                at android.os.Handler.dispatchMessage(Handler.java:102)
                at android.os.Looper.loop(Looper.java:135)
                at android.app.ActivityThread.main(ActivityThread.java:5232)
                at java.lang.reflect.Method.invoke(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:372)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)</p>
  </blockquote>
  
  <p>There is another crash caused by parser before:</p>
  
  <pre><code>07-30 08:40:32.651  22982-23154/? E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
      Process: com.performance_tool, PID: 22982
      java.lang.RuntimeException: An error occured while executing doInBackground()
              at android.os.AsyncTask$3.done(AsyncTask.java:300)
              at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
              at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
              at java.util.concurrent.FutureTask.run(FutureTask.java:242)
              at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
              at java.lang.Thread.run(Thread.java:818)
       Caused by: org.w3c.dom.DOMException: Only one root element allowed
              at org.apache.harmony.xml.dom.DocumentImpl.insertChildAt(DocumentImpl.java:421)
              at org.apache.harmony.xml.dom.InnerNodeImpl.appendChild(InnerNodeImpl.java:52)
              at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:306)
              at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:128)
              at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:107)
              at com.XmlHelper.getNumberOfNodes(XmlHelper.java:29)
              at com.TestCasesActivity$ConfigParser.doInBackground(TestCasesActivity.java:46)
              at com.TestCasesActivity$ConfigParser.doInBackground(TestCasesActivity.java:33)
              at android.os.AsyncTask$2.call(AsyncTask.java:288)
              at java.util.concurrent.FutureTask.run(FutureTask.java:237)
              at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
              at java.lang.Thread.run(Thread.java:818)
  </code></pre>