将数据发送到的WebView加载页面 [英] Send data to page loaded in WebView

查看:107
本文介绍了将数据发送到的WebView加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中的web视图和我加载 http://mysite.com/somepage.php

I have a WebView in my app and I load http://mysite.com/somepage.php

我知道我可以使用GET方法,因为这只会是正确的URL字符串传递数据。我想知道我怎么可以传递数据,使用POST方法的页面。我试图寻找,但我无法找到任何具体。谢谢你。

I know I can pass data using the GET method because that would just be right in the URL string. I was wondering how I could pass data to the page using the POST method. I tried searching but I cannot find anything specific. Thanks.

推荐答案

有一个在的WebView名为 postUrl 的方法

There's a method called postUrl in WebView.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    WebView webView = new WebView(this);
    setContentView(webView);

    String url = "http://mysite.com/somepage.php";
    String postData = "postvar=value";

    webView.postUrl(url, EncodingUtils.getBytes(postData, "base64"));
}

如果的base64 没有工作,请尝试 BASE64 或者

If base64 didn't work, try BASE64 alternatively.

希望它会正常工作。

这篇关于将数据发送到的WebView加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆