I will answer my own question to provide additional information if somebody else needs a similar strange setup as mine :-) The answer provided by user3431672 is one part of the solution. This ensures that no stuff is loaded from the Internet by the WebView.
Additionaly I created a custom WebViewClient and implemented the shouldInterceptRequest
which fires at least for all GET requests. My own communication component fetches the data and returns the method with a WebResourceResponse
if no redirect was followed. If there was a redirect during fetching the data for the request I don't return the WebResourceResponse
. Instead I call loadDataWithBaseURL(...)
and return the shouldInterceptRequest()
method with null
.
To be able to handle POST requests I had to implement a custom class to inject JavaScript and add it to the WebView via addJavaScriptInterface()
. With this class I register an EventListener on all button
elements and, when clicked, go through all the input
elements (and whatever else I need) to parse my data for the POST request. The POST request is then handled by my communication component and the response is again loaded via loadDataWithBaseURL(...)
.
Hope this helps somebody.