title: Crash when calling onBackPressed()
body: <p>I am sending API request to send email and on successful response I am calling <strong>onBackPressed()</strong> in my <strong>EmailActivity</strong> class.</p>
  <p>I have also <strong>AbstractBaseActivity</strong> class which is extended by my <strong>EmailActivity</strong> class.</p>
  <p>I am getting this crash very often.</p>
  <pre><code>Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Handler android.app.FragmentHostCallback.getHandler()' on a null object reference
         at android.app.FragmentManagerImpl.ensureExecReady + 2003(FragmentManager.java:2003)
         at android.app.FragmentManagerImpl.execPendingActions + 2056(FragmentManager.java:2056)
         at android.app.FragmentManagerImpl.popBackStackImmediate + 870(FragmentManager.java:870)
         at android.app.FragmentManagerImpl.popBackStackImmediate + 831(FragmentManager.java:831)
         at android.app.Activity.onBackPressed + 3111(Activity.java:3111)
         at android.support.v4.app.FragmentActivity.onBackPressed + 187(FragmentActivity.java:187)
         at com.test.test.core.AbstractBaseActivity.onBackPressed + 71(AbstractBaseActivity.java:71)
         at com.test.test.emails.EmailActivity.displayEmailSent + 283(EmailActivity.java:283)
         at com.test.presentation.emails.EmailPresenter.lambda$sendEmail$2$EmailPresenter + 100(EmailPresenter.java:100)
         at com.test.presentation.emails.EmailPresenter$$Lambda$2.accept + 4(:4)
         at io.reactivex.internal.observers.ConsumerSingleObserver.onSuccess + 62(ConsumerSingleObserver.java:62)
         at io.reactivex.internal.operators.single.SingleObserveOn$ObserveOnSingleObserver.run + 81(SingleObserveOn.java:81)
         at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run + 124(HandlerScheduler.java:124)
         at android.os.Handler.handleCallback + 873(Handler.java:873)
         at android.os.Handler.dispatchMessage + 99(Handler.java:99)
         at android.os.Looper.loop + 193(Looper.java:193)
         at android.app.ActivityThread.main + 6718(ActivityThread.java:6718)
         at java.lang.reflect.Method.invoke(Method.java)
         at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 493(RuntimeInit.java:493)
         at com.android.internal.os.ZygoteInit.main + 858(ZygoteInit.java:858)
  </code></pre>
  <p>This is code inside my EmailActivity.</p>
  <pre><code>  @Override public void displayEmailSent() {
      Toast.makeText(this, R.string.email_sent, Toast.LENGTH_SHORT).show();
      onBackPressed();
    }
  </code></pre>
  <p>Here is my code inside AbstractBaseActivity.</p>
  <pre><code>  @Override public void onBackPressed() {
      if(this instanceof AddTaskActivity ||
          this instanceof AddCustomerActivity ||
          this instanceof AddContactsActivity ||
          this instanceof NoteDetailsActivity ||
          this instanceof AddEstimateActivity ||
          this instanceof AddAgreementsActivity ||
          this instanceof AddAppointmentActivity ||
          this instanceof EditServiceLocationActivity) {
        showExitDialogForFormScreens();
      } else {
        super.onBackPressed();
      }
    }
  </code></pre>
  <p>Here is the code from EmailPresenter.</p>
  <pre><code> public void sendEmail(int entityId, EmailType emailType, String emailBody, String subject, List&lt;String&gt; recipients) {
      disposables = RxUtil.initDisposables(disposables);
  
      if(TextUtils.isEmpty(subject)) {
        view.displaySubjectInvalid();
        return;
      }
  
      if(TextUtils.isEmpty(emailBody)) {
        view.displayEmailBodyInvalid();
        return;
      }
  
      if(recipients == null || recipients.isEmpty()) {
        view.displayRecipientsEmpty();
        return;
      }
  
      if(!Utils.isValidEmailAddress(recipients.get(0))) {
        view.displayEmailToInvalid();
        return;
      }
  
      String modelType = getModelType(emailType);
  
      view.disableEmailButton();
  
      Disposable disposable = emailsRepository.sendEmail(entityId, modelType, emailBody, subject, recipients)
          .subscribeOn(Schedulers.io())
          .observeOn(AndroidSchedulers.mainThread())
          .subscribe(response -&gt; {
            view.enableEmailButton();
            if (response.isSuccessful()) {
              view.displayEmailSent();
            } else {
              view.displayEmailError();
            }
          }, throwable -&gt; {
            view.enableEmailButton();
            view.handleError(throwable);});
  
      disposables.add(disposable);
    }
  </code></pre>
  <p>From EmailActivity I am returning to another activity, but if I would return two or three screens it would be return to Fragment,</p>
  <p>How I can solve this?</p>