YoKeyword/Fragmentation · critical · RuntimeException
Must extends FragmentActivity/AppCompatActivity and…
Error message
Must extends FragmentActivity/AppCompatActivity and implements ISupportActivity
What it means
SwipeBackActivityDelegate requires its host to be both a FragmentActivity (for fragment operations) and an ISupportActivity (for fragmentation integration). The constructor throws a RuntimeException if either condition fails, since it casts to FragmentActivity and delegates to the support stack.
Solutions
- Extend SwipeBackActivity from the library, which already satisfies both constraints.
- Or extend AppCompatActivity/FragmentActivity AND implement ISupportActivity (with SupportActivityDelegate) before using SwipeBackActivityDelegate.
Example fix
// before
public class DetailActivity extends Activity {
// after
public class DetailActivity extends SwipeBackActivity { Defensive patterns
Strategy: validation
Validate before calling
if (!(this instanceof FragmentActivity) || !(this instanceof ISupportActivity)) {
throw new IllegalStateException("SwipeBack host must extend FragmentActivity and implement ISupportActivity");
} Type guard
boolean isSwipeBackHost(Activity a) { return a instanceof FragmentActivity && a instanceof ISupportActivity; } Prevention
- Prefer extending SwipeBackActivity directly.
- When building custom bases, always pair SwipeBackActivityDelegate with ISupportActivity implementation.
- Verify both constraints before wiring swipe-back into an activity.
When it happens
Trigger: Instantiating SwipeBackActivityDelegate (or extending SwipeBackActivity using it) from an activity that is not a FragmentActivity or does not implement ISupportActivity.
Common situations: Adding swipe-back to a plain Activity or AppCompatActivity without ISupportActivity; custom base activities missing the ISupportActivity implementation; mixing fragmentation_swipeback with non-support activities.
Related errors
- Must extends FragmentActivity/AppCompatActivity
- Must extends Fragment
- must impl ISupportActivity!
- Threshold value should be between 0 and 1.0
- not attach!
AI-assisted analysis of YoKeyword/Fragmentation@0394930a3e (2026-09-10).
Data as JSON: /api/errors/66467275a5cf9999.
Report an issue: GitHub.
Appendix: source
Thrown at fragmentation_swipeback/src/main/java/me/yokeyword/fragmentation_swipeback/core/SwipeBackActivityDelegate.java:22
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import androidx.fragment.app.FragmentActivity;
import android.view.ViewGroup;
import me.yokeyword.fragmentation.ISupportActivity;
import me.yokeyword.fragmentation.SwipeBackLayout;
/**
* Created by YoKey on 17/6/29.
*/
public class SwipeBackActivityDelegate {
private FragmentActivity mActivity;
private SwipeBackLayout mSwipeBackLayout;
public SwipeBackActivityDelegate(ISwipeBackActivity swipeBackActivity) {
if (!(swipeBackActivity instanceof FragmentActivity) || !(swipeBackActivity instanceof ISupportActivity))
throw new RuntimeException("Must extends FragmentActivity/AppCompatActivity and implements ISupportActivity");
mActivity = (FragmentActivity) swipeBackActivity;
}
public void onCreate(Bundle savedInstanceState) {
onActivityCreate();
}
public void onPostCreate(Bundle savedInstanceState) {
mSwipeBackLayout.attachToActivity(mActivity);
}
public SwipeBackLayout getSwipeBackLayout() {
return mSwipeBackLayout;
}
public void setSwipeBackEnable(boolean enable) {
mSwipeBackLayout.setEnableGesture(enable);
}View on GitHub (pinned to 0394930a3e)