WebView does not allow you to access HTTP response content.
To do this, you need to use HttpClient , and then forward the content to the view using the loadDataWithBaseUrl function and specifying the base URL so that the user can use web browsing to continue navigating the website.
Example:
// Executing POST request HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); httppost.setEntity(postContent); HttpResponse response = httpclient.execute(httppost); // Get the response content String line = ""; StringBuilder contentBuilder = new StringBuilder(); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); while ((line = rd.readLine()) != null) { contentBuilder.append(line); } String content = contentBuilder.toString(); // Do whatever you want with the content // Show the web page webView.loadDataWithBaseURL(url, content, "text/html", "UTF-8", null);
source share