How to avoid ProgressDialog in Android
<p><a href="http://developer.android.com/guide/topics/ui/dialogs.html" rel="nofollow">Dialogs @ Android Developer</a> says to avoid ProgressDialog to indicate loading, and instead, to put an activity indicator right in the layout.</p>

<p><a href="http://developer.android.com/design/building-blocks/progress.html" rel="nofollow">Progress &amp; Activity @ Android Developer</a> discusses activity indicators, but doesn't name the classes used.  I've had no luck searching for Android classes with names like ActivityBar, ActivityCircle, or ActivityIndicator.</p>

<p>Where can I find documentation (tutorials, examples, or API documentation) on Android's support for including activity indicators right in my layout, avoiding a ProgressDialog?</p>

<p><strong>Update:</strong> full.stack.ex pointed me the right answer.</p>

<p>First, include the following code in the Activity's onCreate() method <em>before invoking setContentView():</em></p>

<pre><code>requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
</code></pre>

<p>Next, just before loading (e.g. firing up an AsyncTaskLoader), use this call to make the spinner appear:</p>

<pre><code>setProgressBarIndeterminateVisibility(true);
</code></pre>

<p>Finally, after the load is completed, hide the spinner again:</p>

<pre><code>MainActivity.this.setProgressBarIndeterminateVisibility(false);
</code></pre>

<p>Bingo!  No ProgressDialog required.  Making the spinner visible seems to slow down loading considerably in the emulator (it takes minutes instead of seconds), but not on my actual phone.  I'm not sure if there's any way to make the spinner use fewer CPU cycles.</p>
