Example sharing of several ways of network communication in Android network programming

Nowadays, mobile applications have penetrated into all walks of life, and the number is hard to count. Most of them will use the network, and the interaction with the server is unstoppable. What are the ways to access the network in Android?

Here are six ways:

(1) Socket and ServerSocket for TCP / IP

(2) Datagram socket and datagram package for UDP. It should be noted here that considering that Android devices are usually handheld terminals, IP is allocated with the Internet. Not fixed. Therefore, development is also a little different from ordinary Internet applications.

(3) Httpurlconnection for direct URL.

(4) Google integrates the Apache HTTP client, which can be used for network programming.

(5) Use WebService. Android can support XMLRPC and jsonrpc through open source packages such as Jackson. In addition, it can also use ksoap2 to implement web service.

(6) Display web pages directly using the WebView view component. Based on WebView, Google has provided a web browser based on chrome Lite, which can browse the web directly.

1、 Socket and ServerSocket

Client code

2、 Rul, urlconnection, httpurlconnection, Apache HTTP, WebView

3、 Using webservice

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>