跳转到第二个页面是发生异常
来源:12-3 WebView高可扩展性封装-3
慕九州6385248
2018-09-24
程序打开第一个html页面没有问题,但是跳转到第二个页面时就crash了
java.lang.IllegalStateException: Can't change container ID of fragment WebDelegateImpl{77b1254 #0 id=0x7f0800f3 com.example.latte_core.delegates.web.WebDelegateImpl}: was 2131230963 now 2131230762
at android.support.v4.app.BackStackRecord.doAddOp(BackStackRecord.java:418)
at android.support.v4.app.BackStackRecord.add(BackStackRecord.java:387)
at me.yokeyword.fragmentation.TransactionDelegate.start(TransactionDelegate.java:442)
at me.yokeyword.fragmentation.TransactionDelegate.doDispatchStartTransaction(TransactionDelegate.java:384)
at me.yokeyword.fragmentation.TransactionDelegate.access$400(TransactionDelegate.java:32)
at me.yokeyword.fragmentation.TransactionDelegate$4.run(TransactionDelegate.java:132)
at me.yokeyword.fragmentation.queue.ActionQueue.handleAction(ActionQueue.java:53)
at me.yokeyword.fragmentation.queue.ActionQueue.enqueueAction(ActionQueue.java:45)
at me.yokeyword.fragmentation.queue.ActionQueue.access$000(ActionQueue.java:17)
at me.yokeyword.fragmentation.queue.ActionQueue$1.run(ActionQueue.java:37)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
我看网上的答案是fragment没有commit,猜测可能是接替父类的事件有问题,但是代码和老师的一样啊
参考链接
public final boolean handleWebUrl(WebDelegate delegate,String url){
if (url.contains("tel:")){
callPhone(delegate.getContext(), url);
return true;
}
final LatteDelegate parentDelegate = delegate.getParentDelegate();
final WebDelegateImpl webDelegate = WebDelegateImpl.create(url);
if (parentDelegate == null){
delegate.start(webDelegate);
}else {
parentDelegate.start(delegate);
}
return true;
}
写回答
1回答
-
这样干看确实没办法详细定位,不过这个或许和之前旧版本作者提出的库bug有关,因为之前这些问题我本来是在github的issue看到过。你看看群文件里的模板,里面有最新的依赖写法,库升级的比较多了。还有后面调整的话, 你先注释掉getparent在一块,然后start,如果不报错,就定位到这个问题了。不过建议先把fragmentation升个级
112018-09-26
相似问题