How to make post requests with webview?

后端 未结 2 1628
被撕碎了的回忆
被撕碎了的回忆 2020-12-10 05:58

I want to make an http post request using webview.

webView.setWebViewClient(new WebViewClient(){


            public void onPageStarted(WebView view, String         


        
2条回答
  •  攒了一身酷
    2020-12-10 06:17

    First add the support of the http library to your gradle file: To be able to use

    useLibrary 'org.apache.http.legacy'

    After this you can use the following code to perform post request in your webview:

    public void postUrl (String url, byte[] postData)
    String postData = "submit=1&id=236";
    webview.postUrl("http://www.belencruzz.com/exampleURL",EncodingUtils.getBytes(postData, "BASE64"));
    

    http://belencruz.com/2012/12/do-post-request-on-a-webview-in-android/

提交回复
热议问题