Address: http://www.cnblogs.com/linzheng/archive/2011/01/23/1942365.html
1. Java socket programming introduction http://www.cnblogs.com/linzheng/archive/2011/01/23/1942328.html
II. Introduction to URL and urlconnection Network Programming
Iii. Introduction to HTTP Network Programming
HTTP protocol-Overview HTTP protocol-C # obtain webpage source code HTTP protocol-multi-thread File Transfer
Iv. Web Service Network Programming
V. Introduction to network programming for Android webview
Instance code -----------------------------------------------
Code
Code package COM. amaker. socket; import Java. io. ioexception; import Java. io. outputstream; import java.net. serversocket; import java.net. socket;/*** socket server, which writes Hello android to the client! */Public class myserver {public static void main (string [] ARGs) {try {serversocket Server = new serversocket (8888); While (true) {Socket Client = server. accept (); outputstream out = client. getoutputstream (); string MSG = "Hello android! "; Out. Write (msg. getbytes (); client. Close () ;}} catch (ioexception e) {e. printstacktrace ();}}}
Server Simulation
Myserver. Java
Code
Loginservlet. Java
Code
Web. xml
<? XML version = "1.0" encoding = "UTF-8"?>
<Web-app version = "2.4"
Xmlns = "http://java.sun.com/xml/ns/j2ee"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemalocation = "http://java.sun.com/xml/ns/j2ee
Http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd>
<Servlet>
<Servlet-Name> loginservlet </servlet-Name>
<Servlet-class> com. Amaker. http. loginservlet </servlet-class>
</Servlet>
<Servlet-mapping>
<Servlet-Name> loginservlet </servlet-Name>
<URL-pattern>/servlet/loginservlet </url-pattern>
</Servlet-mapping>
</Web-app>
Android Client
Mainactivity. Java
Code
Androidmanifest. xml
Code
I. socket programming
Testsocketactivity. Java
Code
Socket. xml
Code
Ii. url and urlconnection Programming
Testurlactivity. Java
Code
Test_url.xml
Code
Iii. Http Programming
Loginactivity. Java
Code
Http1.xml
Code
4. Web Service Programming
Testwebserviceactivity. Java
Code
Weatheractivity. Java
Code
Webserviceutil. Java
Code
Weather. xml
Code
V. webview Programming
Testwebviewactivity. Java
Code
Test_webview.xml
Code