LoginSignup
2
2

More than 5 years have passed since last update.

CrossWalkで頻発する network change was detected の対処方法

Last updated at Posted at 2016-03-14

CrossWalk 17.46.448.10で確認しています。

そもそもなぜ CrossWalkを使うのか

Android4.4.2で発生する、WebViewでfile chooserがオープンできないバグ
http://stackoverflow.com/questions/23568792/android-4-4-webview-file-chooser-not-opening

のためだけにCrossWalkを使用しています。
早く絶滅しないものか。

しかし、時々

network change was detected

というメッセージが出て処理が止まります。
ちなみに以前はダイアログでしたが最近のCrossWalkではToastでメッセージが出ます。
でも処理が進まないのは変わらないのでたいして意味はありません。

対処法

//呼び出し元
XWalkView view = new XWalkView(this);
XWalkView view.setResourceClient(new MyXWalkResourceClient());


.
.
.


public class MyXWalkResourceClient extends XWalkResourceClient {
.
.
.
   @Override
    public void onReceivedLoadError(XWalkView view, int errorCode, String description, String failingUrl) {
        if(errorCode == -1){
            // network change was detected.
            view.load(failingUrl, null);
            return;
        }
        super.onReceivedLoadError(view, errorCode, description, failingUrl);
    }

該当する場合は強制的にロードし直しているだけです。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2