Simple IntroductionRead the in-depth understanding of Android network programming feels good. Today's Android network programming is a key record.ContentAndroid Web-based technology and programming practices
Points
Defined
Descriptive narrative
IP protocol
A data-oriented prot
traffic on the device through the Virtual Network Card. The procedure is as follows:
Obtain the device udid from itunes
Open the terminal and create a virtual network card
Enter rvictl-s udid in the terminal to create the virtual network card.
Start tcpdump to monitor traffic
Basic Android tutorial -- 7.6.1 Socket Learning Network BasicsBasic Android tutorial -- 7.6.1 Socket Learning Network Basics
Tags (separated by spaces): basic Android tutorial
This section introduces:
In order to take care of beginners who have never learned Java Socket, o
", data.length () + "");//post mode, in fact, the browser to the data to the server Conn.setdooutput (TRUE); Set the output stream outputstream OS = Conn.getoutputstream (); Gets the output stream Os.write (Data.getbytes ()); Write data to server int code = Conn.getresponsecode (); if (code = =) {InputStream is = Conn.getinputstream (); return STREAMTOOLS.S Treamtostring (IS);} else {return "network access Failed";}} catch (Exception e) {e.printstackt
and look for it. I will not explain it.
ØADB push c: \ wherever_you_put \ tcpdump/data/local/tcpdump
Modify file attributes
ADB Shell
Su
Chmod 6755/data/local/tcpdump
Command Line packet capture
/Data/local/tcpdump-p-VV-S 0-W/Sdcard/capture. pcap-Which path do you write by the way?
(If tcpdump: no suitable device found appears. Make sure that you are using the root permission)
^ C after the packet capture is complete and exit Android bash
ADB pull/
the first connect fails. This is necessary for Ipv4+ipv6 and for services hosted in redundant data centers. OkHttp initiates new connections with modern TLS features (SNI, ALPN), and falls back to TLS 1.0 if the handshake fails. Using OkHttp is easy. Its Request/response APIs are designed with fluent builders and immutability. It supports both SyNchronous blocking calls and async calls with callbacks. OkHttp supports Android 2.3 and above. For Java,
Android basics tutorial -- 7.6.1 Socket Learning Network basics, android7.6.1Basic Android tutorial -- 7.6.1 Socket Learning Network Basics
Tags (separated by spaces): basic Android tutorialThis section introduces:
In order to take care of beginners who have never learned
versions is a good choice. In Android 2.3 and later versions, HttpURLConnection is the best choice. Its API is simple and small, therefore, it is very suitable for Android projects. The compression and cache mechanisms can effectively reduce network access traffic and play a major role in improving speed and saving po
to start the response caching feature. The following example code shows how to enable the response cache feature in Android 4.0 and later, without affecting the previous version:[Java]View Plaincopy
Private void Enablehttpresponsecache () {
try {
long httpcachesize = Ten * 1024x768 * 1024; //MiB
File Httpcachedir = new File (Getcachedir (), "http");
Class.forName ("Android.net.http.HttpResponseCache")
. GetMethod ("Install", File.
(requests header) and the returned content (Response header and content), such as:You can find that fiddler can view the data returned by the network request in various formats, including header, TextView (text), ImageView (picture), Hexview (hex), WebView (Web Form), Auth ( Proxy-authenticate header), Caching (header cache), Cookies, Raw (original data format), JSON (JSON format), XML (XML format) is very convenient.Stop
keepalive conditionVi. on the timely cessation of meaningless network requests:Sometimes some network requests may become a waste request, they not only crowding out the thread pool resources, accounting for memory, run more traffic, more power, and even cause memory leaks. For example, the user opened an activity, the activity opened a number of
Android practitioners, ten are doing network applications, not the Internet is also a local area network. Now in the world of 4G and WiFi, traffic is already floating clouds, single-use market has been quietly gone. So, do not understand the network request students to be ca
loadImageIfNecessary (fals E) ;}// if the image has been moved off the screen and becomes invisible, the cancelling request @ Override protected void onDetachedFromWindow () {if (mImageContainer! = Null) mImageContainer. cancelRequest (); super. onDetachedFromWindow ();}}When a ListView loads multiple images, NetworkImageView can prevent image errors and cancel the image loading request when the NetworkImageView slides out of the screen, this ensures the smoothness of the sliding list when load
Network applications are mainly used for searching, Browsing webpages, sending emails, and sending mms. For android, some intermediate processes involved in these applications mainly involve webkit, wap, smtp and other protocols, socket communication, and then
The tcpip protocol stack and ppp protocol of Linux kernel are followed by device interfaces such as ttyS0, and data is sent by modem. In addition, th
Network applications are mainly used for searching, Browsing webpages, sending emails, and sending MMS. For Android, some intermediate processes involved in these applications mainly involve WebKit, WAP, SMTP and other protocols, socket communication, TCPIP protocol stack of Linux kernel, and PPP protocol, the device interfaces such as ttys0 are followed by the modem to send data. In addition, the
This article mainly introduces a QoS solution, the article from the blog Park Rtc.blacker, welcome to the public number blacker, more details on www.rtc.helpBackground of the advent of QoS:And when the network congestion, all the traffic can be discarded, in order to meet the different application of different service quality requirements, the network can be base
Android phone can be WiFi internet, this is good. But when there is no WiFi, how to go on Ah, 3G---> Limited traffic, watching video is not cost-effective! Here I summarize several methods for your reference.Method One: USB cable, mobile phone wired internet1, connect the phone via USB cable to the computer, check the "settings, wireless and network binding and p
First, the problem description
Android applications often involve loading a large number of images from the network, in order to improve loading speed and efficiency, reduce network traffic will adopt the two-level cache and asynchronous loading mechanism, so-called two-level cache is by first get from memor
1. Introduction
Currently, images are inevitably used in android applications. Some images can be changed and need to be pulled from the network at each startup, there are many such scenarios in advertising spaces and pure image applications (such as Baidu meipai.
Now there is a problem: If you pull images from the network every time you start, it will inevitab
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.