The WebView loadurl (string Url,map header) method in Android and the PostURL (string url,byte[] postdata) method Use the problem at the same time;

Source: Internet
Author: User

First, the Loadurl (String Url,map header) is the method used to load the add request header in the WebView

PostURL (String url,byte[] postdata) is the method used to load the add request body in WebView

But the pit is that if you want to add both the request header and the request body both methods are not available, and the android comes with the WebView does not provide a method

After searching on StackOverflow, it is useful to do other third-party encapsulated HTTP requests, but it is troublesome to say here my own approach, not necessarily for everyone,

But absolutely rude, I used the Loadurl (String Url,map header) method to stitch my request body into the URL

namely url=url+ "body=" +body;

Then use the Loadurl (String Url,map header) method to replace the URL with the request body URL, the request header is written in the MAP format, the problem is resolved, the need to do is to let the background support get method request.

My method is finished, say a digression, their first blog, and later prepared to put their own problems, especially the Chinese site can not solve the problem posted, the method is not necessarily suitable for everyone,

But it's definitely your own test success. Also hope that those who often reprint some of the wrong blog people do not waste other people's search time (at least to run their own and then reproduced it), do this line of all know

I have a problem. It's a waste of time to search for the same blog that has the wrong story.

The WebView loadurl (string Url,map header) method in Android and the PostURL (string url,byte[] postdata) method Use the problem at the same time;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.