androidcrosswalkxwalkview

Crosswalk onJsBeforeUnload counterpart


Is there a method wherein I can override the onJsBeforeUnload in XWalkUIClient like this in WebChromeClient?

      @Override
      public boolean onJsBeforeUnload(WebView view, String url, String message, final JsResult result) {
        new Thread(new Runnable() {
          @Override
          public void run() {
            handler.post(new Runnable() {
              @Override
              public void run() {
                result.confirm();
              }
            });
          }
        }).start();

        return true;
      }

I'm trying to use Crosswalk's onJsPrompt and onJsAlert but I have no success in getting the result of onJsBeforeUnload.

Thanks!


Solution

  • Apparently I haven't tried onJavascriptModalDialog. I was able to imitate onJsbeforeUnload's behavior using

      @Override
      public boolean onJavascriptModalDialog(XWalkView view, JavascriptMessageType type, String url, String message, String defaultValue, final XWalkJavascriptResult result) {
            new Thread(new Runnable() {
              @Override
              public void run() {
                handler.post(new Runnable() {
                  @Override
                  public void run() {
                    result.confirm();
                  }
                });
              }
            }).start();
    
            return true;
          }