Introduction
I have thoroughly understood Android network programming. Today I have recorded the key points of Android Network Programming.
Content
Android Network-based technology and programming practices
Key Points |
Definition |
Description |
IP protocol |
A data-oriented protocol for Packet Exchange Networks |
|
TCP protocol |
Transmission Control Protocol and transport layer communication protocol. |
|
UDP protocol |
User Datagram Protocol and transport layer protocol. |
|
SMTP protocol |
Simple Mail Transfer Protocol |
|
SOCKET |
The intermediate software abstraction layer for communications between the application layer and the TCP/IP protocol family. |
There are two types: TCP socket and UDP socket. |
TCP socket |
|
In terms of reliability, the mechanism of timeout retransmission and RST validation is adopted, and the sliding window protocol is used for traffic control. In terms of congestion control, the slow start algorithm is used. |
UDP socket |
|
Compress network data traffic into data packets. |
FTP protocol |
The file transfer protocol and the Transport Protocol application layer. |
Apache packages can be operated directly. |
Telnet protocol |
Standard remote login Protocol |
Apache packages can be operated directly. |
Differences between C ++ and JAVA sockets |
Socket is the original Socket development interface Api in Winsock. |
1. Different interfaces, java itself does not have the underlying implementation of socket communication, but calls the second encapsulation of the winsock api at the underlying system level. C ++ is closer to winsock at the system level, you can perform more underlying scaling and control. 2. java developed to run on a java virtual machine. |
Difference between UDP and TCP |
|
1. Reliable tcp and unreliable udp 2. tcp supports the following application protocols: telnet, ftp, smtp, and tcp, which allow users to transmit large amounts of data. 3. udp-supported application protocols: nfs (Network File System), snmp (Simple Network Management System), dns (Primary Domain Name System), and tftp universal file transfer protocol, the amount of data transmitted by users is small. 4. tcp is java.net. ServerSocket (for the server side) and java.net. Socket (for the client side); UDP is java.net. DatagramSocket. 5. stream mode and datagram mode: TCP ensures data correctness and UDP may cause packet loss. TCP ensures data sequence, but UDP does not.
|
|
|
|
Android basic Web technology and programming practices
Key Points |
Definition |
Description |
HTTP protocol |
The application layer protocol of the distributed hypermedia information system. Http: // host [":" port] [path] |
Features: 1. Supports the C/S mode. 2. simple and fast 3. Flexible 4. No connection 5. Stateless Two types of packets: request packets and response packets. |
HTTP Programming |
Supported functions include: Automatic redirection, https protocol, proxy server, methods (get, post, put, head, opption, connect) |
Implementation: Data Request, data upload, data deletion, and other operations. Operable classes: HttpClient and URLConnection. |
JSON |
JavaScript Object Notation, lightweight text data exchange format. |
Operable classes: JSONObject, JSonArray, JSONArray, JSONTokener, and JSONStringer. |
SOAP |
Simple Object Access Protocol and application layer protocol. |
Included elements: Envelope, Header, Body, and Fault. |
HTML |
Hypertext Markup Language |
The methods for parsing Html documents include: 1. Regular Expression 2. Locate strings 3. HTML Parser 4. Jsoup parser |
How to encrypt it? |
Data transmission can be encrypted by adding an encryption algorithm |
Encryption algorithms include: Custom displacement (Others), MD5 (irreversible), symmetric encryption (DES, AES), and asymmetric encryption (RSA) You can introduce the crypto package. |
|
|
|
Programming of common Android network interfaces
Key Points |
Definition |
Description |
XML |
Scalability marking speech |
Use XmlSerializer to create an XML file |
DOM Parsing |
An XML parsing method has the following features: All content of an XML file is stored in the memory in the form of a document tree. Then, you can use DOM APIs to traverse the XML tree and retrieve the required data. |
Required classes: DocumentBuilderFactory, Document, Element, NodeList. |
SAX Parsing |
It is an XML parsing method and has the following features: loading and parsing based on event-driven. |
Required classes: XMLReader, ContentHandler, DTDHandler, ErrorHandler, EntityResolver |
PULL Parsing |
Same as above |
|
RSS |
Simple Information aggregation: A format used to describe and synchronize website content. Subscription: blog and news. |
|
Email Programming |
As the name implies: send an email. |
1. Use the built-in email service. 2. Use the javamail feature package to send emails. |
Encryption and decryption |
Encryption is the process of converting plaintext into ciphertext through encryption algorithms and encryption keys. |
1. Base64 encryption (character represents binary data) 2. DES is the Data Encryption Standard 3. AES is an Advanced Encryption Standard 4. Use MD5 to ensure information transmission integrity |
OAuth Authentication |
An open standard that allows third parties to use. |
Four steps: 1. Obtain the token of an unauthorized request 2. Get the token of the user authorization request 3. Use the authorization request token for authentication token 4. access using the authenticated token |
Differences Between DOM and SAX |
The loading method is different. DOM loads all content at a time, while SAX loads and reads it. |
|
|
|
|
Android Network module programming
Key Points |
Definition |
Description |
USB Programming |
Universal Serial Bus, a master-slave structure. |
Involved classes: USB Manager, USB accessory, USB device, and USB endpoint |
WIFI Programming |
802.11b standard, industrial standard for wireless communication, features: fast, reliable, and far away. The direct connection technology of wifi is to connect directly through wifi. |
Related Classes: WirelessSettings, WifiSettings, AccessPointDialog, metrics, WifiLayer, WifiManager, WifiState, metrics, WifiMonitor, WifiNativie, ScanResult, WifiInfo, and wifiConfiguration. Five layers: hardware drivers, wpa_supplicant, JNI, Wifi Api, and WifiSettings applications. Classes involved in direct connection: WifiP2pManager |
Bluetooth Programming |
A wireless technology supporting short-distance communication between devices |
Involved classes: effecthadapter, effecthdevice, and effecthsocket |
NFC Programming |
There are three working modes of short-range wireless communication: active, passive, and bidirectional. Applications: Contact pass, contact payment, contact connection, and contact browsing. |
Involved classes: NfcAdapter, NdefMessage, and NdefRecord |
|
|
|
Voip applications based on the Sip protocol
Key Points |
Definition |
Description |
Sip protocol |
The Session Initiation Protocol is used to establish, modify, and terminate interactive sessions, including video, voice, instant messaging, online games, virtual reality, and other multimedia elements. |
The signaling control protocol at the application layer. |
What protocol is used for transmission? |
UDP and TCP |
|
Comparison between H.323 protocol and SIp protocol |
1. H.323 uses the binary method of ASN.1 and compression encoding rules to represent its messages. sip is based on the text protocol. 2. h.323 is a multi-point control unit. All terminals send control messages to mcu. sip is a distributed call model and has the multicast function. |
|
What is the composition of a sip session? |
Four components: 1. SIP User Agent (terminal device) 2. SIP registration server (including databases in the locations of all user proxies in the domain) 3. SIP Proxy Server (interface UA's session request and query the SIP registration server to obtain the recipient's UA address information) 4. SIP redirection server (allowing the Sip proxy server to direct the information about the sip session invitation to an external domain) |
|
|
|
|
XMPP-Based Instant Messaging
Key Points |
Definition |
Description |
XMPP protocol |
Scalable Message Processing site protocol |
An xml-based open real-time communication protocol. |
Android XMPP client address |
Http://asmack.freakempire.de/ |
|
|
|
|
Android HTML processing
Key Points |
Definition |
Description |
Key HTML processing classes |
The key Android HTML processing classes are in the frameworks/base/core/java/android/webkit directory of the source code. |
|
Key classes and descriptions |
1. AccessibilityInjector injects accessible javaScript and related content into WebView. 2. AutoCompletePopup is automatically incomplete based on input content 3. BrowserFrame encapsulates the java layer of the Frame object in WebCore. 4. CacheManager Cache Management object. 5. CallbackProxy proxy class for processing WebCore and UI thread messages 6. CerTool WebView certificate Tool 7. ClientCerRequestHandler processes client certificate requests 8. lelemessage javaScript console message 9. Cookiemanager Cookies management object 10. CookieManagerClassic Cookiemanager extension implementation class 11. CookieSyncManager: Cookies are managed synchronously, and Cookies between RAM and FLASH are synchronized. 12. DataSorter date sorting 13. DebugFlags 14. DevicemotionAndOrientationManager implements DeviceMotion and DeviceOrientation 15. DeviceMotionService implements the SensorEventListener interface to handle changes in the direction. 16. Downloadlistener download listener 17. FindActionModeCallback search action callback 18. permission management of GeolocationPermissions WebView's geographic location JavaScript Api 19. GeolocationPermissionsClassic GeolocationPermissions extension class, which processes WebKit threads called in the UI thread. 20. GeolocationService encapsulates location listening. 21. HTML5Audio audio support Class 22. HTML5VideoFullScreen full screen video View 23. HTML5VideoInline Embedded Video View 24. HTML5VideoView Video View 25. HTML5VideoViewProxy video view processing class 26. HttpAuthHandler processes http authentication requests 27. JWebCoreJavaBridge is used to bridge the interaction between java and the timer and Cookies in the webcore library. 28. The category class used by JniUtil JNI to obtain information that cannot be directly obtained by C Code such as the cache directory and read files in the resource package. 29. The JsPromptResult js result prompt prompts the javascript running result. 30. JsResult js results for user interaction. 31. KeyStoreHandler installs the certificate to the system key storage area and reads the certificate from the network and sends it to CertTool. 32. L10nUtils is responsible for internationalization of strings |
33. MimeTypeMap MIME type ing 34. MockGeolocation simulate geographic location information 36. MustOverrideException extension runtime error 37. OverScrollGlow is used to implement OverScroller results 38. Plugin defines the plug-in class 39. PluginData plug-in Data 40. PluginFullScreenHolder obtains the container size of the plug-in view and is responsible for display and other operations. 41. PluginList: maintenance plug-in list 42. PluginManager plug-in management 43. PluginStub WebView implementation plug-in Interface 44. QuadF defines a quadrilateral 45. SearchBox Search dialog box Interface 46. Implementation of the SearchBoxImpl Search dialog box Interface 47. SelectActionModeCallback: Select action callback 48. SslCertLookupTable determines whether a user uses a certificate. 49. Users who choose to save the client certificate by using SslClientCertLookupTable 50. SslErrorHandler handles SSL errors 51. Processing class for URLUtil URL 52. valueCallback callback interface for returning data values Asynchronously 53. ViewManager view management class and Management plug-in view 54. ViewStateSerializer WebView serialization and deserialization 55. List of historical data displayed in the WebBackForwardList WebView object 56. WebBackForwardListClient browser client interface for historical Processing 57. WebChromeClient Chrome Client 58. WebCoreThreadWatchdog WebCore Watchdog 59. WebHistoryItem webpage data 60. WebIconDatabase icon database management object 61. WebIconDatabaseClassic WebIconDatabase extension class 62. WebResourceResponse encapsulate resource response information 63. Manage settings data of WebSettings WebView, which can be obtained from the underlying layer through the JNI interface. 64. WebStorage Database 65. The WebSyncManager Data Synchronization management object is used for synchronization of RAM data and FLASH data. 66. WebTextView displays the native editing component of the system when the HTML text input control is activated. 67. WebView object 68. The WebViewClient Web View client object is notified when an event occurs in the web View. 69. WebViewDatabase Database 70. Embed WebViewFactory WebView into Fragment. 71. Embed WebViewFragment ebView into Fragment. 72. ZoomControlBase scaling control interface. 73. ZoomControlEmbedded built-in scaling control. 74. ZoomManager maintains the scaling status of the WebView. |
|
|
|
Android Network Processing Analysis
Key Points |
Definition |
Description |
Key network processing |
The key types of Android HTML network processing are in the frameworks/base/core/java/android/net directory. |
|
Key classes and descriptions |
1. ConnectivityManager is used to query the network connection status. 2. Credentials UNIX identity information 3. DhcpInfo: The result object of a Dhcp Request 4. Use LocalServerSocket to create non-standard classes for downstream unix domain sockets 5. LocalSocket creates a non-server socket in the unix domain namespace 6. LocalSocketAddress socket address 7. MailTo parse the url in the mailto protocol format 8. NetworkInfo describes the network interface status 9. Proxy access user and default Proxy setting class 10. SSLCertificateSocketFactory implements additional ssl operations 11. SSLSessionCache ssl session cache 12. TrafficStats network traffic statistics 13. An Immutable url reference of Uri 14. Uri. Builder creates a url reference helper class 15. url query by UrlQuerySanitizer 16. UrlQuerySanitizer. illegalactervaluesanitizer uses the characters they contain to filter invalid values. 17. Simple tuples of UrlQuerySanitizer. ParameterValuePair parameter value pairs 18. VpnService application extension and establishment of the basic class of your own vpn solution 19. VpnService. Builder creates a vpn interface helper class |
|
Android-encapsulated http processing class |
1. AndroidHttpClient (essentially the implementation of the Apache DefaultHttpClient class on Android) 2. DefaultHttpClient (an Http client) 3. SSL authentication information processing (the implementation of SSL protocol is related to digital certificates, including SslCertificate and SslError) |
1. AndroidHttpClient cannot be executed in the main thread, and DefaultHttpClient can be executed in the main thread. 2. AndroidHttpClient obtains the instance through the static method newInstance, and DefaultHttpClient creates the object. 3. DefaultHttpClient starts the Cookie by default, but does not retain the Cookie by default. to retain the Cookie, you need to add CookieStore to HttpContext. |
Android RTP protocol |
Real-time transmission protocols are used to provide end-to-end real-time transmission services for multiple real-time multimedia data transmitted over IP networks, such as voice, image, and fax. The RTP protocol details the standard packet formats for transmitting audio and video. |
Involved classes: AudioCodec, AudioStream, AudioGroup, and RtpStream. |
Summary
The book explains in detail the key points of Android development, and uses the source code case to explain in detail, so that the author can deepen his understanding of related knowledge points in principle.