How can I get the JSON response of a POST request in a WebView?

You should override the shouldOverrideUrlLoading method of WebViewClient

public boolean shouldOverrideUrlLoading (WebView view, String url) {

    if(flag) { 

            URL aURL = new URL(url); 
            URLConnection conn = aURL.openConnection(); 
            InputStream is = conn.getInputStream(); 
            // read inputstream to get the json..
            return true;

    return false

public void onPageFinished (WebView view, String url) {
    if (url contains "form.html") {
        flag = true;

Also take a look at this How do I get the web page contents from a WebView?

Leave a Comment