0

I am developing an app that has an embbed webpage that runs javascript. The javascript executes requests, and I would like to intercept them. I need this because I need the user to use the webview without an internet connection. I want to save the requests and execute later when he is connected.

What I have tried:

  • WebViewClient: this class has shouldInterceptRequest but it only provides the url, I need more info (headers and body).

    mWebview.setWebViewClient(new WebViewClient() {
        @Override
        public WebResourceResponse shouldInterceptRequest(WebView view,
                String url) {
            return super.shouldInterceptRequest(view, url);
        }
    });
    
  • Setting a custom proxy and creating a SocketServer to listen to the proxy port and intercept the request. This approach is too risky for me.

Therefore I would like to know if there is another way. Any help is greatly appreciated.

Community
  • 1
  • 1
luksfarris
  • 1,313
  • 19
  • 38
  • Can you give an example of such a javascript request? Are you familiar with the WebView JavaScriptInterface? – greenapps Jun 17 '14 at 18:55
  • The .js is provided by a third party, and I cannot change it. I don't see how JavaScriptInterface can help me. – luksfarris Jun 18 '14 at 12:37
  • You were not asked to change or show the javascript. Only to give an example of how such request would look like. – greenapps Jun 18 '14 at 12:46

0 Answers0