WizarDroid icon indicating copy to clipboard operation
WizarDroid copied to clipboard

Second time using wizard fragment I get a NPE

Open donhill opened this issue 8 years ago • 0 comments

I am calling the wizard fragment from my one activity. Currently I only use one Activity for all views using the following getSupportFragmentManager().beginTransaction() .replace(R.id.nav_container, new RegistrationWizard()) .commit();

This works fine the first time but if I call the wizard a second time it loads fine but on the click to next I get the following error. I did notice that on the sample you there was a call to finish(). I can't really do this as my app would be over. It looks like on the second call that getActivity() returns null.

Any thoughts on how to properly get this working or do I need todo something differant on the finish, I am currently just calling the following in onWizardComplete() .

getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.support.v4.app.FragmentActivity.getSystemService(java.lang.String)' on a null object reference at org.codepond.wizardroid.WizardFragment.onStepChanged(WizardFragment.java:53) at org.codepond.wizardroid.layouts.BasicWizardLayout.onStepChanged(BasicWizardLayout.java:102) at org.codepond.wizardroid.Wizard$2.onPageScrollStateChanged(Wizard.java:117) at android.support.v4.view.ViewPager.dispatchOnScrollStateChanged(ViewPager.java:1873) at android.support.v4.view.ViewPager.setScrollState(ViewPager.java:460) at android.support.v4.view.ViewPager.smoothScrollTo(ViewPager.java:914) at android.support.v4.view.ViewPager.scrollToItem(ViewPager.java:623) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:609) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:570) at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:551)

donhill avatar Jun 19 '16 18:06 donhill