How to send POST data with code in an android webview

后端 未结 3 1237
刺人心
刺人心 2020-12-13 13:26

I have an android application that consists of a WebWiew and I need to login to a site automatically using code. I\'ve tried using postUrl() and it

3条回答
  •  伪装坚强ぢ
    2020-12-13 14:13

    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"));
    }
    

提交回复
热议问题