Load a POST request into a WebView in Android

The standard way to load an URL into a WebView object is using the loadUrl method.

public void loadUrl (String url)

But if we need to load an URL into the WebView submitting POST data, use instead the postUrl method.

public void postUrl (String url, byte[] postData)

To create the POST data, use a string and encode it.

String postData = "submit=1&id=236";

webview.postUrl(
    "http://www.belencruzz.com/exampleURL",
    EncodingUtils.getBytes(postData, "BASE64"));
Share Button

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload the CAPTCHA.