title: Start activity inside a Rx Subscriber
body: <p>We are trying to handle an error when I receive a response from a back-end. If the response is successful we are starting a new activity, on the other hand if the response is not successful we invoke the onError method.</p>
  
  <p>We have the feeling we are not handling properly the lifecycle due we open a new activity, our subscription gets unsubscribed, so we do not dismiss the dialog properly. Should we store a variable in subscriber inner class to ask for that in onComplete, and in that method start the new activity? Or this aproximation is good enough?</p>
  
  <pre><code>Subscriber&lt;BackendResponse&gt; subscriber = new Subscriber&lt;BackendResponse&gt;() {
          @Override
          public void onCompleted() {
              progressDialog.dismiss();
          }
  
          @Override
          public void onError(Throwable exception) {
              progressDialog.dismiss();
              SnackbarNotification.show(coordinatorLayout, "Error");
          }
  
          @Override
          public void onNext(BackendResponse backendResponse) {
              if (backendResponse.getSuccess()){
                  startActivity(new Intent(LoginActivity.this, HomeActivity.class));
              } else {
                  onError(new Exception("Launch onError"));
              }
          }
      };
  </code></pre>
  
  <p>Moreover, are we handling in the correct way the onError flow? We know that invoking the onError from onNext it will cause to call on Error and after that call onComplete. Should we unsubscribe the subscriber on the onError method?</p>
  
  <p>We have found a wrapper for the subscriber:</p>
  
  <pre><code>public abstract class DefaultSubscriber&lt;T&gt; extends Subscriber&lt;T&gt; {
      protected T result;
  
      @Override
      public void onCompleted() {
          onSuccess(result);
      }
  
      @Override
      public void onError(Throwable e) {
          CustomLog.e("onError", e.getMessage());
          onFailure(e);
      }
  
      @Override
      public void onNext(T t) {
          result = t;
      }
  
      protected abstract void onSuccess(T t);
  
      protected abstract void onFailure(Throwable exception);
  }
  </code></pre>
  
  <p>Doing so, we store the result provided by onNext in a member variable. Once the stream has been finished (only one iteration) we call onSuccess (result) inside onCompleted. On the other hand we handle the onError in onFailure method. What do you think about that? Are we missing something?</p>