Android Network Programming record

Source: Internet
Author: User
Tags http authentication unix domain socket file transfer protocol ftp protocol asymmetric encryption

Brief introduction

Read in-depth understanding of Android network programming feels good, today on the Android network programming to make a point record.


Content

Android Web-based technology and programming practices

Points Defined Describe



IP protocol
A data-oriented protocol for message exchange networks
TCP protocol Transmission Control Protocol, transport-layer communication protocols.
UDP protocol User Datagram Protocol, Transport layer protocol.
SMTP protocol Simple Mail Transfer Protocol
Socket sockets The intermediate software abstraction layer that the application layer communicates with the TCP/IP protocol family. There are two kinds of types: TCP sockets and UDP sockets.
TCP sockets In the guarantee reliability, using the time-out retransmission and the pass-through confirmation mechanism, in the flow control, adopts the sliding window protocol, in the congestion control, adopts the slow-start algorithm.
UDP sockets Compress the network data traffic into the form of a packet.
FTP protocol File Transfer Protocol, the application layer of the transport Protocol. Can operate Apache's package directly
Telnet protocol Standard protocol for Remote login services Can operate Apache's package directly
Differences between C + + and Java sockets The socket is the original socket development interface API in Winsock. 1, the interface is different, the Java itself does not have the socket communication bottom implementation, but calls the system's underlying Winsock API two encapsulation; C + + is closer to the system-level Winsock, enabling more underlying scaling and control.
2. Java can be developed to run on the Support Java Virtual machine.
UDP and TCP differences 1, TCP reliable, UDP unreliable
2, TCP supports the application protocol has: TELNET,FTP,SMTP,TCP can transmit the data of large number of users
3, UDP Support Application Protocol: NFS (Network File system), SNMP (Simple Network management System), DNS (primary domain Name System), TFTP universal File Transfer Protocol, etc., the user transmits less data.
4, TCP is Java.net.ServerSocket (for the server side) and Java.net.Socket (for the client); UDP is Java.net.DatagramSocket.
5. Stream mode and datagram mode: TCP guarantees data correctness, UDP may drop packets, TCP guarantees data order, UDP does not guarantee.


Android basic Web technology and programming practices

Points Defined Describe
HTTP protocol Application layer Protocol of Distributed hypermedia Information System.
/HTTP Host [":" Port] [path]
Characteristics:
1. Support C/S mode
2, simple and fast
3. Flexible
4. No connection
5. No status
Two types of messages: Request messages, response messages.
HTTP programming
Supported Features: auto-turn, HTTPS protocol, Proxy Server, method (get, post, put, head, opption, connect)
Implementation: Data request, data upload, data deletion and other operations.
Actionable classes: HttpClient and URLConnection.
Json JavaScript Object notation, lightweight text data Interchange format. Actionable classes:
Jsonobject, Jsonarray, Jsonarray, Jsontokener, Jsonstringer.
Soap Simple Object Access Protocol, Application layer protocol. Included elements: Envelope, Header, Body, Fault.
Html Hypertext Markup Language The methods for parsing HTML documents are:
1. Regular expressions
2. String positioning
3. HTML Parser Parser
4. Jsoup Parser
How to encrypt? Data transfer can add an encryption algorithm for encryption Cryptographic algorithms are: custom Displacement (other), MD5 (irreversible), symmetric encryption (DES, AES), asymmetric encryption (RSA)
The crypto package can be introduced.

Android Common Network Interface programming

Points Defined Describe
Xml Extensible tagging Voice Creating an XML file using XmlSerializer
Dom parsing A way of parsing XML, characterized by storing all the contents of an XML file in memory in the form of a document tree, and then using the DOM API to traverse the XML tree and retrieve the required data. The Required classes:
Documentbuilderfactory, Document, Element, NodeList.
Sax parsing A way of parsing XML, features: event-driven, edge-loaded edge parsing. The Required classes:
XMLReader, ContentHandler, Dtdhandler, ErrorHandler, Entityresolver
Pull parsing Ditto
Rss Simple information aggregation, a format for describing and synchronizing web site content. Subscribe: Blogs, news.
Email programming As the name implies: Send mail. 1. Use the system's own mail service.
2, the use of JavaMail function package to send mail.
Add decryption Encryption is the process of converting plaintext into ciphertext through cryptographic algorithms and cryptographic keys, and decryption is reversed. 1, Base64 encryption (character means binary data)
2, DES is the data Encryption Standard
3, AES is the Advanced Encryption Standard
4, MD5 use to ensure the integrity of information transmission
OAuth Authentication An open standard that allows users to use third parties. Four steps:
1. Obtaining an unauthorized request token
2. Obtain the user authorized request token
3, with the authorized request token change Authentication token
4. Access using authentication token
The difference between DOM and sax Loading in different ways, the DOM loads all the content at once, and sax reads it while loading.


Android Network module programming

Points Defined Describe
USB programming Universal Serial Bus, a master-slave structure. The classes involved:
Usbmanager, Usbaccessory, Usbdevice, Usbendpoint
WiFi programming 802.11B Standard, the industry standard of wireless communication, features: fast speed, reliable, far away.
WiFi Direct connection technology is directly connected via WiFi.
Related classes: Wirelesssettings, Wifisettings, Accesspointdialog, Wifienabler, Wifilayer, Wifimanager, WifiState, WifiService, Wifimonitor, Wifinativie, Scanresult, Wifiinfo, Wificonfiguration.
User perspective Five layers: Hardware driver, wpa_supplicant, JNI, Wifi Api, wifisettings application.
Classes involved in direct connection: Wifip2pmanager
Bluetooth programming A wireless technology to support short-distance communication of equipment Classes involved: Bluetoothadapter, Bluetoothdevice, Bluetoothsocket
NFC Programming Near-distance wireless communication technology, 3 modes of operation: active, passive, two-way. Application: Contact through, contact payment, contact connection, contact browsing. Classes involved: Nfcadapter, Ndefmessage, Ndefrecord

The application of VoIP based on SIP protocol

Points Defined Describe
SIP protocol Session Initiation Protocol for creating, modifying, and terminating interactive sessions, including video, voice, instant messaging, online games, and multimedia elements such as virtual reality. Signaling control protocol for the application layer.
What protocol is used for transmission? UDP protocol and TCP protocol
The comparison of the Protocol and the SIP protocol 1. The binary method of ASN.1 and compression coding rules is used to express its message, SIP is based on text protocol.
2, the multi-point control unit, all terminals to the MCU to send control messages; SIP is a distributed call model with multicast capability.
What constitutes a SIP session? Four components:
1, SIP user agent (terminal equipment)
2. SIP registration Server (database containing the location of all user agents in the domain)
3, SIP Proxy Server (interface UA session request and query the SIP registration server, get the address information of the recipient UA)
4. SIP redirection Server (allow SIP proxy to talk about SIP session invitation information directed to external domain)

Instant communication based on XMPP protocol

Points Defined Describe
XMPP protocol Extensible Message Processing Site Protocol An open real-time communication protocol based on XML.
The XMPP client address for Android http://asmack.freakempire.de/


Android's handling of HTML

Points Defined Describe
HTML Processing Key class Android HTML Processing key class in the source Frameworks/base/core/java/android/webkit directory
Key classes and descriptions 1. Accessibilityinjector provides WebView with access to JavaScript and its related content.
2, Autocompletepopup according to the input content is not complete automatically
3. Browserframe the Java layer encapsulation of the frame object in the WebCore.
4, CacheManager cache management object.
5, Callbackproxy processing WebCore and UI thread message proxy class
6. Certool WebView Certificate Tool
7. Clientcerrequesthandler Processing Client certificate Request
8. Consolemessage JavaScript Console messages
9. Cookiemanager Cookie Management Object
10. Cookiemanagerclassic Cookiemanager Extended Implementation class
11, Cookiesyncmanager cookie Synchronization Management object, responsible for synchronizing the RAM and flash between the cookies data.
12, Datasorter date sorting
13. DebugFlags Debug Mark
14, Devicemotionandorientationmanager realize Devicemotion and deviceorientation
15, Devicemotionservice realizes Sensoreventlistener interface, processing direction change.
16, Downloadlistener download monitor
17. Findactionmodecallback Search Action Callback
18. Geolocationpermissions WebView's Location JavaScript API Rights Management
19. Geolocationpermissionsclassic geolocationpermissions Extension class that handles WebKit threads that are called in the UI thread.
20, Geolocationservice package position monitoring.
21. Html5audio Audio Support class
22. Html5videofullscreen Full Screen Video view
23. Html5videoinline Embedded Video View
24. Html5videoview Browser Video View
25. Html5videoviewproxy Video View Processing class
26, Httpauthhandler processing HTTP authentication request
27, Jwebcorejavabridge for Java and WebCore Library timer and cookie object interaction Bridge
28. The utility class used by Jniutil JNI to obtain the information that C code such as the cache directory cannot obtain directly, and to read the files in the resource bundle.
29, Jspromptresult JS results hint, prompted JavaScript running results.
30, Jsresult JS results, user interaction.
31, Keystorehandler is responsible for installing the certificate to the System key store, read the certificate from the network to Certtool.
32. L10nutils is responsible for the internationalization of strings
33. Mimetypemap MIME Type mapping
34, mockgeolocation simulation location information
36. Mustoverrideexception Extended run-time error
37. Overscrollglow used to achieve overscroller results
38. Plugin defines the plug-in class
39, Plugindata plug-in data
40, Pluginfullscreenholder get plug-in view of the size of the container, responsible for display and other operations.
41, pluginlist Maintenance plug-in list
42, PlugInManager plug-in management class
43, Pluginstub WebView Implementation plug-in interface
44. QUADF defines a quadrilateral
45. SearchBox Search dialog Box interface
46, Searchboximpl Search dialog box interface implementation
47. Selectactionmodecallback Select Action Callback
48. Sslcertlookuptable the decision to store whether a user is using a certificate
49, Sslclientcertlookuptable Save the client certificate user selection
50. Sslerrorhandler Handling SSL Error
51. Urlutil URL using processing class
52. Valuecallback callback interface for returning data values asynchronously
53. Viewmanager View Management class, manage plug-in view
54. Viewstateserializer WebView View serialization and deserialization
55. List of historical data displayed in the Webbackforwardlist WebView object
56, Webbackforwardlistclient browsing History Processing Client interface
57. Webchromeclient Chrome Client
58. Webcorethreadwatchdog WebCore Watchdog
59, Webhistoryitem a Web page data
60. Webicondatabase Icon Database Management Object
61. Webicondatabaseclassic Webicondatabase Extension class
62. Webresourceresponse Package Resource response information
63, WebSettings WebView management settings data, through the JNI interface from the bottom to obtain.
64. WebStorage Database
65. Websyncmanager data synchronization Management object for synchronous operation of RAM data and flash data.
66. Webtextview displays the system native editing component when the HTML text input control is activated.
67. WebView View Object
68. Webviewclient The Web View client object, which is notified when an event occurs in the Web view.
69. Webviewdatabase Database
70, Webviewfactory WebView embedded in fragment.
71, Webviewfragment Ebview embedded in fragment.
72, Zoomcontrolbase zoom control interface.
73, zoomcontrolembedded built-in zoom control.
74, Zoommanager Maintenance WebView Zoom state.


Android Network Processing Analytics

The
Points Defined Describe
Network processing Key class Android HTML network processing key classes in the source frameworks/base/core/java/android/net directory
key class and describes the status of 1, Connectivitymanager for querying network connections.
2, Credentials unix identity information
3, dhcpinfo   A DHCP Request result object
4, Localserversocket   Create a non-standard class for the downstream UNIX domain socket
5, Localsocket   Create a non-server socket in the UNIX domain namespace
6, localsocketaddress  socket address
7, MailTo   Parse the MAILTO Protocol format URL
8, networkinfo Description network interface Status
9, proxy Access user and default proxy settings class
10, sslcertificatesocketfactory   Additional details for SSL operations
11, Sslsessioncache  ssl Session cache
12, trafficstats   network traffic statistics
13, Uri   An immutable URL reference
14. Uri.builder   Create an auxiliary class for URL reference
15, urlquerysanitizer   Filter URL query
16, Urlquerysanitizer.illegalcharactervaluesanitizer filter illegal values with the characters they contain
17, Urlquerysanitizer.parametervaluepair Simple tuple of parameter value pairs
18, vpnservice   Apply extension and build your own VPN solution base class
19, Vpnservice.builder   Create a secondary class for the VPN interface
 
HTTP processing classes for Android encapsulation 1, androidhttpclient (essentially Apache Defaulthttpclient class on Android implementation)
2, Defaulthttpclient (an HTTP client)
3, the SSL authentication Information processing class (SSL protocol implementation and the digital certificate correlation, relates the class: Sslcertificate, Sslerror)
1. Androidhttpclient cannot be executed in the main thread, Defaulthttpclient is executed in the main thread.
2. Androidhttpclient obtains the instance through the static method Newinstance, and Defaulthttpclient creates the object.
3, defaulthttpclient The default start cookie, but the default does not retain cookies, if you want to retain the need to add Cookiestore to HttpContext.
Android RTP Protocol Real-time transmission protocol, which is used to provide end-to-end real-time transmission service for multimedia data such as voice, image, fax and so on in IP network.
The RTP protocol details the standard packet format for delivering audio and video.
Classes involved: Audiocodec, Audiostream, Audiogroup, Rtpstream.



Summarize

The book explains in detail the main points of Android development, and the source case for detailed explanation, so that the author from the principle of deepening the understanding of the relevant knowledge points.


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.