You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
问题:如果连续发生拦截七八次左右,拦截器就会失效,跳转也会失效,arouter不能跳转了,等待几分钟,又会重新路由到拦截界面,日志就只看到了 Navigation failed, termination by interceptor : The interceptor processing timed out.[ ] 。不知道是什么原因,
@interceptor(priority = 1, name = "login")
public class LoginInterceptor implements IInterceptor { @OverRide
public void process(Postcard postcard, InterceptorCallback callback) {
switch (postcard.getPath()) {
case UserRouterConstant.GUIDE:
case UserRouterConstant.USER_SPLASH:
case UserRouterConstant.HOME:
case UserRouterConstant.LOGIN:
case UserRouterConstant.USER_SET_PWD:
callback.onContinue(postcard);
break;
default:
if (UserInfoConfig.userInfo == null) {
ARouter.getInstance().build(UserRouterConstant.LOGIN).navigation();
} else {
callback.onContinue(postcard);
}
}
}
@Override
public void init(Context context) {
// 拦截器的初始化,会在sdk初始化的时候调用该方法,仅会调用一次
}
Activity
tqlmorepassion commentedon May 25, 2018
拦截发生的第八次的时候,就会失效,所有router就会路由失败,
tqlmorepassion commentedon May 25, 2018
@zhi1ong
zhi1ong commentedon Jun 16, 2018
和拦截多少次没关系,首先拦截器无论被拦截还是放过都要调用 onContinue 或者 onInterrept, 其次要注意在拦截器中发起跳转的时候,新跳转最好要加 greenChannal, 防止被重复拦截
songnick commentedon Aug 24, 2023
这个问题是因为在拦截器里面我们直接返回了,并没有执行callback.onContinue(postcard);方法导致的,这部分可以看看源码:

如果需要跳转到其他页面,可以设置一个tag:
postcard.setTag("Error");
callback.onContinue(postcard);