title: I want to use a progress bar with RxJava like you can with AsyncTask
body: <p>I want to replace my AsyncTask with RxJava in android.  My current AsyncTask goes like this: </p>
  
  <pre><code>public class ProgressBarAsyncTask extends AsyncTask&lt;Void,Void,Void&gt; { 
  
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          ringProgressDialog = ProgressDialog.show(context,"MyProgressBarTitle","Working please wait",true, false);                  
      }
  
      @Override
      protected Void doInBackground(Void... void) { 
         //do work
         myTask();
         return null;
      }
  
      @Override
      protected void onPostExecute(Void void) {
          super.onPostExecute();
          ringProgressDialog.dismiss();
      }
  }
  </code></pre>
  
  <p>Here's my RxJava replacement:</p>
  
  <pre><code>    public static Observable&lt;Void&gt; getObservable(final Context context,final String... params) {
  
         return Observable.defer(new Func0&lt;Observable&lt;Void&gt;&gt;() {
            @Override
            public Observable&lt;Void&gt; call() {
               return Observable.just(myTask());
            }
         });
  
     }
  
      public static Subscriber&lt;Void&gt; getSubscriber() {
      Subscriber&lt;Void&gt; subscriber = new Subscriber&lt;Void&gt;() {
          @Override
          public void onCompleted() {
             ringProgressDialog.dismiss();
  
          }
  
          @Override
          public void onError(Throwable e) {
              Log.d(TAG,e.toString());
  
          }
  
          @Override
          public void onNext(Void aVoid) {
               manipulateData();
  
          }
      };
      return subscriber;
  }
  </code></pre>
  
  <p>My Activity:</p>
  
  <pre><code>public class MainActivity extends Activity { 
     private ProgressDialog ringProgressDialog;
  
     @Override
     protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        GetNumberObservable.Observable()
                         .subscribeOn(Schedulers.io())
                         .observeOn(AndroidSchedulers.mainThread()))
                         .subscribe(getSubscriber());
     }
  }
  </code></pre>
  
  <p>How do I mimic the onPreExecute() method in the AsyncTask where I kick off the progressDialog?        </p>