JetradarMobile / android-multibackstack

Persistent bottom navigation like in instagram
Apache License 2.0
216 stars 28 forks source link

Getting NullPointerException when trying to startActivityForResult from fragment #9

Closed egek92 closed 6 years ago

egek92 commented 6 years ago

In my fragment I need to start activity for result but

 Process: com.magis.icbc, PID: 810
                  java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
                      at android.support.v4.app.BackStackRecord.doAddOp(BackStackRecord.java:392)
                      at android.support.v4.app.BackStackRecord.replace(BackStackRecord.java:439)
                      at android.support.v4.app.BackStackRecord.replace(BackStackRecord.java:430)
                      at com.magis.icbc.ui.components.activity.MainMenuActivity.replaceFragment(MainMenuActivity.java:428)

replace method gives NPE

private void replaceFragment(@NonNull Fragment fragment) {
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction tr = fm.beginTransaction();
    tr.replace(R.id.frame_container, fragment);
    tr.commitAllowingStateLoss();
    curFragment = fragment;
  }
egek92 commented 6 years ago

ok I guess this was a logcat malfunction showing the exception in the wrong place, turned out it was giving exception because I was calling getSupportActionBar() in NoActionBar theme. Closing the issue, it has nothing to do with the backstack

kopilim96 commented 5 years ago

Does the issue solve ? I think I have some idea and I solved my problem of the issue as yours