How to post data for WebView android

后端 未结 5 1333
挽巷
挽巷 2020-12-25 12:29

I need to post data to Webview.
I found from some of the links the below code:

 WebView webview = new WebView(this);
 setContentView(webview);
 String u         


        
5条回答
  •  抹茶落季
    2020-12-25 13:14

    For those who came here by trying to put a html body as a postData and not working, try to put your string body as something below:

        val htmlCode = "https://ramdom.user.me"
    
        val postData = "{\n" +
                "\t\"token\": \"963966f649\"\n" + "}"
    
        webview.postUrl(htmlCode, postData.toByteArray())
    

    I hope to save someone`s life. :-)

提交回复
热议问题