What is the most robust HTTP library for android?

2020-02-19 06:24发布

I'm looking for a library that handles HTTP POST, multipart etc. Is there a de-facto standard library to make these requests easier on android?

标签: android http
7条回答
啃猪蹄的小仙女
2楼-- · 2020-02-19 06:35

Use http-request by Kevin Sawicki. http://kevinsawicki.github.com/http-request/

查看更多
看我几分像从前
3楼-- · 2020-02-19 06:41

Take a look at http://loopj.com/android-async-http/

Overview says: An asynchronous callback-based Http client for Android built on top of Apache’s HttpClient libraries. All requests are made outside of your app’s main UI thread, but any callback logic will be executed on the same thread as the callback was created using Android’s Handler message passing.

This library was used by popular apps such as Instagram, Pinterest, Heyzap and etc.

查看更多
老娘就宠你
4楼-- · 2020-02-19 06:43

There is something that I have been doing. It extends loopj library with handlers and loaders that create POJO's. https://github.com/MarkoMilos/android-http

查看更多
劫难
5楼-- · 2020-02-19 06:47

My favorite one is Ion (complete, under active development). It is built on top of AndroidAsync (to use alone if you don't need Ion features), both by Koushik Dutta.

  • Asynchronously download
  • Easy to use Fluent API designed for Android
  • HTTP POST/PUT
  • Transparent usage of HTTP features and optimizations
  • View received headers
  • Grouping and cancellation of requests
  • Download progress callbacks
  • Supports file:/, http(s):/, and content:/ URIs
  • Request level logging and profiling
  • Support for proxy servers like Charles Proxy to do request analysis
  • Based on NIO and AndroidAsync
  • Ability to use self signed SSL certificates
查看更多
放荡不羁爱自由
6楼-- · 2020-02-19 06:54

If you want to use keep alives and gzip and dont want to experience random time out errors unfortunately you cannot simply use one library.

On Android SDK versions below 9 you'll want to use the apache library. On Android SDK versions 9-13 the apache library has issues (random timeouts) and you'll want to use HttpUrlConnection.

Unfortunately in my tests on ICS HttpUrlConnection is really buggy and you'll want to use the Apache library for now.

Official Google Post on the topic: http://android-developers.blogspot.com/2011/09/androids-http-clients.html

Issue i've found on ICS: What android Http Client to use for Ice Cream Sandwich?

查看更多
疯言疯语
7楼-- · 2020-02-19 06:58

Take a look at DroidFu, and in particular the DroidFu HTTP components. They're a fairly thin wrapper around the Apache Commons HTTP stuff, but they fit most needs pretty well. It includes some niceties like optional HTTP and model caching, and even "why isn't this built in to the platform" stuff like GZip. (An aside: android.net.AndroidHttPClient is a pretty good upgrade to the older stock DefaultHttpClient stuff when you need to drop down for a little more control, but it's Android 2.2+ only and is fairly underdocumented).

If you just need multipart with a minimum hassle, you can try android_multipart_post, though I've never tried it.

EDIT:

DroidFu is now discontinued. These days if I was starting a new project I'd almost certainly use Volley, with OKHttp if I needed more control (you can even use OKHttp as the transport layer for volley if you want to do both).

查看更多
登录 后发表回答