How to show the loading dialog
<p>I try use below code to load an URL.</p>

<pre><code>URL url = new URL(urlstr);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setConnectTimeout(10000);
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
InputStream is = connection.getInputStream();  //spend lots of time
</code></pre>

<p>Because the line <code>InputStream is = connection.getInputStream();</code> will spend some time.
So I want to show a loading dialog while it loading.
I can I do it?</p>

<p>In AActivity, below code to call BActivity.</p>

<pre><code>Intent intent = new Intent(AActivity.this, BActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);  
Window w = MyGroup.group.getLocalActivityManager().startActivity("BActivity", intent);  
View view = w.getDecorView();  
MyGroup.group.setContentView(view);
</code></pre>

<p>And BActivity is load URL and extract information.
The load code is in onCreate().</p>

<p>I try the answer code, the error <code>Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@2afe9488 is not valid; is your activity running?</code> shows.</p>
