With what can I replace http deprecated methods?

后端 未结 4 929
迷失自我
迷失自我 2021-01-02 15:15

I was following a tutorial and I got to a point where a lot of the code is deprecated.

ArrayList dataToSend = new ArrayList<>();
d         


        
4条回答
  •  温柔的废话
    2021-01-02 15:42

    I found that I can replace NameValuePair with

    Not really.

    but I have no idea about the others

    The entire HttpClient API that ships with Android itself is deprecated. The solution is to use a different HTTP client:

    • HttpUrlConnection, from standard Java
    • third-party ones, like OkHttp
    • Apache's repackaged HttpClient for Android

    With respect to the tutorial, either:

    • Use tutorials that do not use a deprecated HTTP API, or
    • Port the tutorial to use Apache's repackaged HttpClient for Android, or
    • Ignore the deprecation warnings

提交回复
热议问题