There are many ways to communicate with remote servers in Android, and today we describe using the HTTP protocol to get data from a remote server.In Android, you can use three interfaces and servers for HTTP communication:1. Java standard interface:
Using HttpURLConnectionThere are generally two ways to send HTTP requests on Android, HttpURLConnection and HttpClient, and now learn the nextThe use of httpurlconnection.First, you need to obtain an instance of HttpURLConnection, typically just a
Rt.. I previously felt that Android network communication is amazing, magic ... Recently learned the network knowledge, now to summarize how to doWell, let's take an example to illustrate the principle.The use of this demo:1. Users can access a Web
ArticleDirectory
Proxy and username/password
Bypass a proxy
You have to set the following properties:
HTTP. proxyhost (default: ) HTTP. proxyport (default: 80 if HTTP. proxyhost specified) HTTP. nonproxyhosts (default: )
Note:
Android: Network Operations in android and android
There is no difference between network operations in android and java. Many network operation methods in java can be moved to android for use. The main points are as follows:
1. Differences between
Android getting started-network communication-HttpURLConnection
There are many ways for Android to communicate with remote servers. Today we will introduce how to use http to obtain data from remote servers.
In android, you can use the following
1. obtain data from the Internet:
1. Using the httpurlconnection object, we can obtain webpage data from the network.
URL url = new URL ("http://www.sohu.com ");
Httpurlconnection conn = (httpurlconnection) URL. openconnection ();
Conn.
First, the client obtains json data from the server.
1. Use HttpUrlConnection
Copy codeThe Code is as follows :/**
* Get an array from the specified URL
* @ Param urlPath
* @ Return
* @ Throws Exception
*/
Public static String readParse (String
(1) Principle of resumable Data Transfer
In fact, the principle of resumable upload is very simple, that is, the Http request is different from the general download.
For example, when a browser requests a file on the server, the request is as
This is an episode I've been trying to meet with HttpURLConnection.String urltext = "http://???.?????. com/"; try { url url = new URL (urltext); HttpURLConnection conn = (httpurlconnection) url.openconnection ();
1. Obtain a webpage from the Internet
Send a request to read the webpage back as a stream.
1) create a URL object: URL url = new URL ("http://www.sohu.com ");
2) use the httpurlconnection object to obtain webpage data from the Network:
Java web api call and javawebapiWeb Services is standardized by W3C.
Web Services can be published to a Global Registry and automatically provide service URLs, service descriptions, interface call requirements, parameter descriptions, and return
JAVA advanced-Network Programming> Connect to the server through a socketSocket refers to Socket> Read the homepage of any website---------
/** * @author Lean @date:2014-10-9 */public class SocketSample {public static void main(String[] args)
Basic knowledge of the network:In Java, the network program has two protocols: TCP and UDP,TCP are reliably connected by a handshake protocol, and UDP is not connected.IP Address: The identity card used to mark a computer.The IP address consists of
This article was posted on my blog This time to see how our clients connect Jobtracker with URLs. We've built a pseudo-distributed environment and we know the address. Now we look at the files on HDFs, such as address:
Basic knowledge of the network:In Java, the network program has two protocols: TCP and UDP,TCP are reliably connected by a handshake protocol, and UDP is not connected.IP Address: The identity card used to mark a computer.The IP address consists of
Multi-threaded downloads are a way to speed up downloads by opening multiple threads to perform a task. You can make tasks run faster ... Multi-threaded task downloads are always available. For example, our mobile phone internal application treasure
(a) The principle of the continuation of the breakpoint
In fact, the principle of the continuation of the breakpoint is very simple, is the HTTP request and the general download is different.
For example, when a browser requests a text on the
Today, when debugging the app, the httpurlconnection to get the server data with the java.io.FileNotFoundException exception, the reason is not clear, but has found a solution.
Because we have two types of server data, one is XML (request with
--statement, the brain remnants of the people away, the core of this blog is not the if-else+ prefix, but how to define the private protocol through the URL Protocol processing framework
The difference between a URI and a URL
URI (Uniform
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.