How to send POST data with code in an android webview How to send POST data with code in an android webview android android

How to send POST data with code in an android webview


Try replacing "utf-8" (in the 2nd param) with "BASE64".


public void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    WebView webView = new WebView(this);    setContentView(webView);    String url = "http://example.com/somepage.php";    String postData = "postvar=value&postvar2=value2";    webView.postUrl(url, EncodingUtils.getBytes(postData, "base64"));}


WebView myWebView = (WebView) findViewById(R.id.webview);String url="http://www.example.org/login";String postData=                "username="+URLEncoder.encode("abc","UTF8")+                "&password="+URLEncoder.encode("***", "UTF-8");myWebView.postUrl(url,postData.getBytes());