1. Download *
1. multi-thread download
Enable multiple threads, specify the same URL, and specify the same file
Different threads specify different ranges when requesting URLs, and different writes write seek () to different locations when writing the same file
Each thread is responsible for downloading part of it.
2. resumable upload
During the download process, the completed progress is saved for each part of the data downloaded.
At the beginning of the next time, read the progress of the previous completion from the file.
Ii. Handler *****
1. What is handler?
Handler can be used for communication between threads. The interface components in android can only be modified in the thread that creates the interface. If the main thread creates the interface, the new thread cannot be modified.
In some cases, we must modify the main thread interface in the new thread, and then we can use handler to communicate.
2. How to Use
Sendmessdage
In the new thread, call the sendmessage () method through the reference of handler to send a message object
The thread that creates the handler executes the handlemessage () method to obtain the message object sent by the new thread.
Post
Call the post () method through the reference of handler in the new thread to send a runnable object
The thread that creates the handler executes the run () method in runnable.
3. ANR exception
1. What is an ANR exception?
Application not Response Application Program No response. When the user does an operation but the Android system does not process it within 6 seconds, an ANR exception occurs in the program.
2. Why does ANR exception occur?
The processing of user operations in the Android system is performed in the main thread. If our program performs some time-consuming operations in the main thread, the user's operations cannot be processed in 6 seconds, an exception occurs.
3. How can this problem be solved?
Place time-consuming operations in the new thread for execution
If you need an operation interface, use handler for processing.