Placeholder Image

字幕列表 影片播放

  • HttpURLConnection is one HTTP client

  • that you can use to make HTTP requests in Android.

  • Now, you can also use third-party libraries that

  • weren't created by Google.

  • For example, OKHttp is a popular open-source HTTP client

  • created by the Square Mobile Payments Company.

  • They've done a lot of open-source work for Android.

  • This class helps you send and

  • receive data across the web using an HTTP connection.

  • Once you have a URL,

  • actually opening up an HTTP connection is actually pretty straightforward.

  • You start by calling url.openConnection.

  • Then to actually fire off the connection, and

  • be ready to return results, you go ahead and you specify the RequestMethod.

  • In this case, we're going to use the GET HTTP method.

  • Then, you go ahead and call Connect and then finally, you call getInputStream

  • on your connection which is going to be the input stream containing the results.

  • Now, despite the of the codes that you see here,

  • the Android platform is actually handling many of the complex networking

  • details on to the hood for you.

  • In other words, Android as an operating system is actually working with your

  • device's hardware to setup connection and handled some of the physical steps

  • that need to happen in order for the communication to work.

HttpURLConnection is one HTTP client

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

A2 初級 美國腔

HttpURL連接 (HttpURLConnection)

  • 19 1
    Shuyang 發佈於 2021 年 01 月 14 日
影片單字