Mike Szczys · May 18, 2013 at 10:00 am

HttpClient Tutorial to Upload and Download with Your App

Developers wanting to interact with the Internet need to choose a package to do the heavy lifting for them. A very common route is to use the built-in HttpClient. The documentation is fairly complete, but it’s a daunting to get started if you’ve never used the package before.

Take a look at the HttpClient tutorial that JFrankie recently posted.  I find his presentation very approachable for the beginner, yet he doesn’t hesitate to move on to the more complex subjects. The guide starts off with a few lines of code used to open a connection, and quickly covers the first gotcha. HttpClient shouldn’t be run in the UI thread, as it presents a blocking function (you don’t know how long it’s going to be before the server answers back). Android will throw an error automatically if you try to do this.

He goes on to wrap the code in an AsyncTask class. This lets it run in a separate thread, launching a method when its work is complete. Most likely you’re looking to download something, a topic which is well covered in the guide. JFrankie wraps up the post by explaining the steps necessary to upload using the HTTP multipart request protocol.

He publicized his article in a Reddit thread, where he also participated in a discussion of the memory leak potential of using AsyncTask. It’s some advice you may want to heed as you build your app around the HttpClient.


_________
Want something on the XDA Portal? Send us a tip!
GermainZ · Jan 30, 2015 at 09:29 pm · no comments

Send Links to Any Nearby Device with CaastMe

There already are many solutions on the Google Play store if you want to send a link to one of your devices -- but what if you wanted to do it quickly without having to install any software or logging in to a website on the recipient end? Most apps require you to do either or both, which can be a hassle (or even a security risk) in some cases. Luckily, XDA Forum Member wyemun has developed CaastMe. Inspired by...

XDA NEWS
Mario Tomás Serrafero · Jan 30, 2015 at 03:39 pm · 3 comments

The Witcher Battle Arena: Hectic Multiplayer MOBA Fun

Do you like MOBAs? Do you like gaming on your phone? Given that MOBAs (multi player battle arenas) have amassed millions upon millions of players, there's a chance you play LoL or DOTA. And here at XDA we love phones, and we spend a lot of time on them, so if you were to like gaming outside of smartphones you probably like some on them too. I personally like neither, and I simply download the latest 3D games to see the progression...

XDA NEWS
Mario Tomás Serrafero · Jan 30, 2015 at 01:37 pm · no comments

LG G4 Could Feature a… 3K Display?

According to myLGphones, a version of the LG G4 will not feature neither a 2K nor a 4K display - but 3K. If you are anything like me, your reaction to this news will be confusion. While we don't have many details about the sources of this leak, it has apparently been confirmed true by a poster at hardare.fr that gave some more details on model names for each version of the upcoming LG flagship. However, these leaks don't point towards all G4...

XDA NEWS