The HTTP protocol works: The client sends an HTTP request to the server, returns the data to the client after the server receives the request, and the client accepts the message and parses it.There are two ways to send HTTP requests in Android, the first is through HttpURLConnection, and the second is through HttpClien
A simple HTTP request is implemented using the following methods in j2s:
123456
HttpConnection conn = (HttpConnection) Connector.open("www.baidu.com", Connector.READ, true);conn.setRequestMethod("GET");conn.setRequestProperty("accept", "*/*");String location = conn.getRequestProperty("location");int resCode = conn.getResponseCode();InputStream stream = conn.openInputStream();
The implementation in
Android often uses HTTP to interact with the server, but if the submitted data is in Chinese, it often appears garbled.1. First change the workbench code to Utf-82. Transcode the English in the requested URL3. Stitch the final URL and request String Test=urlencoder.encode ("Ru Jianwei", "UTF-8"); String urlstring= "H
Looking at a lot of video on the web about how Android uses HTTP POST or get access to Web pages and get data.I also copied a copy to test. and through C #. NET to build a simple backstage, but found that when the transfer, according to the online way to do not get the corresponding results.Here's my request for a sticker.http://bbs.csdn.net/topics/390814679A long time no one to answer this question, we are
In the android project, if an HTTP request is used, the timeout management and exception management of the HTTP request must also be added. In this case, a lot of requests are found on Google, however, it is relatively simple to write, and it is okay to make a demo, which is not perfect in the project. I wrote an example myself. You are welcome to correct it.
N
Reference: http://stackoverflow.com/questions/2742236/android-httpclient
Source code
First, add the permission in androidmanifest. xml:
Uses-PermissionAndroid: Name= "Android. Permission. Internet"> Uses-Permission>Manifest>
Code:
New Thread ( New Runnable (){ Public Void Run () {httpclient = New Defaulthttpclient (); httpget httpget2 = New Httpget
What should I do if the android http-get request contains Chinese characters ?,
Android often uses http to interact with the server. However, if the submitted data contains Chinese characters, garbled characters often occur.
1. First, change the workbench encoding to UTF-8.
2. transcode the request url in English
field name includes non-ASCII characters. It should also be encoded in accordance with the methods specified in RFC 1522.For all multi-part MIME types, each section has an optional Content-type, and the default value is Text/plain. Assume that the contents of the file are returned by the form fill upload. Then the input file is defined as Application/octet-stream, or, assuming you know what type it is, it is defined as the corresponding media type. If a form returns multiple files, they are ret
1. Initial knowledge of HTTPHTTP (Hypertext Transfer Protocol Hypertext Transfer Protocol) is a network application layer protocol, based on TCP/IP, HTTP uses a reliable TCP connection, the default port is 80.The more common HTTP is get and post, except that get is queried by setting parameters in the request URL, and post is sending the data to the Web side as a formHTTP operation under 2.
Brief introduction:Async-http is a foreign open source framework, the author is loopj. is based on the Apache HttpClient Library. It can make the network data request and send, file download and upload conveniently and quickly and efficiently.Characteristics:A clear network request callbackRequest use of ThreadPool to limit concurrent resource usageGet/post based on parameter construction (REQUESTPARAMS) for easyMultipart file upload, big data upload
Android http code response code status code, androidcode
Some common status codes are:
200-the server returns the webpage successfully
404-the requested webpage does not exist
503-server timeout
The complete list of HTTP status codes is provided below.
1xx (temporary response)
Status Code indicating a temporary response and requiring the requester to cont
Android uploads files in two ways. The first is HTTP-based httpurlconnection, and the second is TCP-based socket. The difference between the two methods is that there is a cache mechanism in the httpurlconnection when uploading. If a large file is uploaded, memory overflow occurs. If you use TCP socket to upload data, this problem will be solved.
HTTP: httpurlcon
();41Pairs. add (new BasicNameValuePair (key, parmas. get (key )));42}43}4445Try {46UrlEncodedFormEntity p_entity = new UrlEncodedFormEntity (pairs, "UTF-8 ");47/*48* Put POST data into an HTTP request49*/50HttpPost. setEntity (p_entity );51/*52* Send an actual http post request53*/54TextView TV = (TextView) findViewById (R. id. state );55TV. setText ("start post :");56HttpResponse response = client.exe cu
Sometimes when you want to look at the development of the app to see the HTTP request and response is what, this need to grab the packet, this can get some unknown API, such as can also do some "bad" ...Tools Required:
Fiddler2 Grab Bag (click to download)
Android Phone One PC
First, how to use Fiddler2After the download is complete, the installation process is not mapped.If you set the Fi
As a result of the recent online search for a lot of Android connection to the HTTP method, but 2013 years ago, the method can not be used now, or error, or abandoned, the years left behind the things can only be sorted by themselves.It's really simple, just a httputil generic class. Can implement get and post method, other things, inside can be arbitrarily changed, basically so.parameter, I used a strurlp
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.