How to post data for WebView android

后端 未结 5 1324
挽巷
挽巷 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条回答
  •  Happy的楠姐
    2020-12-25 13:06

    Try like below...

     WebView webview = new WebView(this);
     setContentView(webview);
     String url = "http://www.example.com";
     String postData = "username=" + URLEncoder.encode(my_username, "UTF-8") + "&password=" + URLEncoder.encode(my_password, "UTF-8");
     webview.postUrl(url,postData.getBytes());
    

提交回复
热议问题