When you say 'speed', do you mean development time or runtime? If the former, Apache's wins. If the latter, the speed is going to depend much more heavily on what you the programmer write (regardless of which package you choose) and on network conditions at the time you run.
That said, lots of programmers have found that Apache's package is easier to use for high performance code. That is why Manning Press's "Unlocking Android" says, after briefly discussing the Java package, "Fortunately, Android provides another set of APIs in the form of the Apache HttpClient library that abstract the java.net classes further and that are designed to offer more robust HTTP support and help handle the separate-thread issue." The authors then show how it helps with concrete examples, which you can download from their website even without purchasing the book: it is ch.6 you want. See http://code.google.com/p/unlocking-android/ for more details. In particular, see how he uses ApacheHTTPViaHelper with the "Swiss-army knife" of thread management, Android's Handler and Looper. But see also HTTPRequestHelper and ResponseHandler. As an exercise, think of how you would re-write this example using AsyncTask instead of Looper and Handler;) Now OTOH, if you tried writing all that with the java.net package's classes, you would have to take on a lot more of the thread management yourself, because the APIs are all synchronous; it CAN be done, it is just more tedious and error-prone. On Sep 15, 8:34 pm, cindy <[email protected]> wrote: > How about speed? which one is fast? > > On Sep 15, 5:59 pm, Indicator Veritatis <[email protected]> wrote:> Yes, we > know why. Because Apache's HttpClient (and other closely > > assoc. classes in the org.apache.http package) is a much better API > > than Sun's own HttpUrlConnection (and the rest of java.net's Http > > support). You can do far more work with less code, and it reads much > > better too. > > > So, for example, HttpClient has helper classes that help you deal with > > spinning off a worker thread and doing all the waiting on HTTP there; > > it is designed to work well asynchronously. Sun's HttpUrlConnection > > has nothing of the sort. > > > That said, you don't get to depart from using java.net entirely. You > > should still use it for dealing with URIs and URLs. But not for much > > more. > > > On Sep 15, 2:41 pm, cindy <[email protected]> wrote: > > > > Hi, > > > > I was told it was prefer to use Apache's library HttpClient, instead > > > of java's Http URLConnection. Does any one know why? > > > > Thanks! > > > > Cindy > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

