shouldInterceptRequest(Webview,url) can help you intercept every site request, for example JavaScript, CSS, image. Then inside shouldInterceptRequest(Webview,url) you can use the url parameter for the initial new HTTP request using HttpClient and HttpPOST , here is an example code:
DefaultHttpClient client = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(<"your url for each request">); httpPost.setHeader("<header-name>", "<header-value>"); HttpReponse httpResponse = client.execute(httpPost); //here omit getting content-type and encoding InputStream reponseInputStream = httpReponse.getEntity().getContent();
Then you can put responseInputStream in return WebResourceResponse(<content-type>, <encoding>, reponseInputStream) in shouldInterceptRequest(Webview,url)
if you have a query that doesn't need to add more headers, just filter it and return null , shouldInterceptRequest(Webview,url) will do the rest.
Hope this helps.
source share