-
-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IllegalStateException: Fragment already active #109
Comments
You can't add the same fragment twice. That's not possible in Android's Please make sure you instantiate each Also try if calling |
My current testing is only trying to add a slide from a button click and that is still crashing with the same error. See my code below. package com.fireapps.firedepartmentmanager;
import ...;
import com.heinrichreimersoftware.materialintro.app.IntroActivity;
import com.heinrichreimersoftware.materialintro.slide.FragmentSlide;
import com.heinrichreimersoftware.materialintro.slide.SimpleSlide;
import com.heinrichreimersoftware.materialintro.slide.Slide;
public class FirstSignupActivity extends IntroActivity {
private SimpleSlide loginChooserSlide;
private SimpleSlide loginSlide;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addSlide(new SimpleSlide.Builder()
.title("Welcome!")
.description("Saving time and saving lives! \nThe BEST First Responder system available.")
.background(R.color.md_teal_500)
.backgroundDark(R.color.md_teal_700)
.build());
addSlide(new SimpleSlide.Builder()
.title("Features!")
.description("From responder tracking to incident reporting. Our system can do it all! Think we should add a feature? Let us know!")
.background(R.color.md_cyan_500)
.backgroundDark(R.color.md_cyan_700)
.build());
loginChooserSlide = new SimpleSlide.Builder()
.background(R.color.md_green_500)
.backgroundDark(R.color.md_green_700)
.title("Create an Account or Login!")
.buttonCtaLabel("Get Started!")
.buttonCtaClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new MaterialDialog.Builder(FirstSignupActivity.this)
.positiveText("YES")
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
addSlide(loginSlide);
}
})
.show();
}
})
.build();
loginSlide = new SimpleSlide.Builder()
.title("Login")
.background(R.color.md_green_500)
.backgroundDark(R.color.md_green_700)
.build();
addSlide(loginChooserSlide);
}
} |
You have to ensure that you can't click the material dialog twice. Otherwise the same slide (referencing the same fragment) will be added again. |
At this point I can't even add a slide after the Intro is created. Throwing same error. Not adding the same slide, completely new slide. public class FirstSignupActivity extends IntroActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addSlide(new SimpleSlide.Builder()
.title("Welcome!")
.description("Saving time and saving lives! \nThe BEST First Responder system available.")
.background(R.color.md_teal_500)
.backgroundDark(R.color.md_teal_700)
.build());
addSlide(new SimpleSlide.Builder()
.title("Features!")
.description("From responder tracking to incident reporting. Our system can do it all! Think we should add a feature? Let us know!")
.background(R.color.md_cyan_500)
.backgroundDark(R.color.md_cyan_700)
.build());
addSlide(new SimpleSlide.Builder()
.background(R.color.md_green_500)
.backgroundDark(R.color.md_green_700)
.title("Create an Account or Login!")
.buttonCtaLabel("Get Started!")
.buttonCtaClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addSlide(new SimpleSlide.Builder()
.title("Login")
.background(R.color.md_green_500)
.backgroundDark(R.color.md_green_700)
.build());
notifyDataSetChanged();
}
})
.build());
}
}` |
Ok, so I've narrowed the issue down, if you provide a description it works and doesn't crash. If you don't give a description it crashes. Edit: It's only crashing sometimes now, one time it'll work fine, restart and it crashes. |
Any progress? This is holding up my project finish. |
Well, I checked the issue. As of my testing the issue only occurs when you add the slide twice. I would consider that normal behavior as your code should ensure to not let users add the same slide twice. I'll look into that again and I'll try to add some checks that prevent that internally. |
When attempting to add a new slide via a callback from a fragment slide, a IllegalStateException is thrown.
The text was updated successfully, but these errors were encountered: