本文介绍了将数据发送到 WebView 中加载的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用中有一个 WebView,我加载了 http://mysite/somepage.php
I have a WebView in my app and I load http://mysite/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/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屋!
更多推荐
[db:关键词]
发布评论