【问题标题】:Android Studio Apache functionsAndroid Studio Apache 函数
【发布时间】:2015-08-19 13:00:40
【问题描述】:

我一直在尝试通过以下方式创建DefaultHttpClient object

HttpClient client = new DefaultHttpClient();

但我找不到此类无法在我的 Android Studio 中解决。 谷歌搜索该类后,第一个结果显示以下 URL:Link

它是404: not found page.

有谁知道我如何使用这个函数和类似的函数,例如 HttpGet?

【问题讨论】:

    标签: java android apache


    【解决方案1】:

    使用 url 连接。如果我没记错的话,defaulthttpclient 已被弃用。

    URL url = new URL("http://stackoverflow.com");
    URLConnection conn = url.openConnection();
    InputStream in = new BufferedInputStream(conn.getInputStream());
    

    【讨论】:

    • urlconnection 是一个抽象类
    • 编辑了答案以反映我的意思。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-13
    • 1970-01-01
    • 2015-08-07
    • 2017-06-06
    • 1970-01-01
    • 2018-05-16
    相关资源
    最近更新 更多