--okhttp Learning for Android Web request

Source: Internet
Author: User

Before doing the Android project, HTTP requests are httpurlconnection and HttpClient in the Android API, the coding is cumbersome, and the package itself is not good. It was later known that there were a lot of Web requests for third-party frameworks that could be easily integrated into our projects, more stable and prescriptive than the Web requests we wrote. Among them, Okhttp was well received, so it took some time to understand and learn.

1. For okhttp use tutorial, please click.

2. The okhttp was encapsulated by the Hon Yang Great God, and the coding became more streamlined. Click here for details.

3, in reading the blog of the Great God, solve some confusing points of knowledge.

3.1. What is the difference between sychronized (Xxx.class) and sychronized (this)?

Synchronized (Threadtest.class) is the ThreadTest this class to lock, class inside the properties, methods are synchronous, the singleton mode is used in this way;

Synchronized (this) {} is a lock on the contents of {}, just for the current object.

3.2. What is Creator mode?

Time to use: when the system needs to create a complex object, and this complex object is more cumbersome to assemble, use the creator mode.

Please click here for details.

3.3, the callback function understanding.

My understanding of the callback function is this: Class A calls a method C (callback function) of Class B, and the logic in method C can be customized by a. Click here for details.

--okhttp Learning for Android Web request

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.