Android : Use common HTTP-related code for Android app and Java program

on Sunday, September 14, 2014


I have developed a Java program that uses org.apache.http, and I would like to reuse most of the functionality in an Android app. I would also like to still be able to use my library in my Java program as I add functionality to it. That's why I'm looking for a way to share a single component that I could improve over time, so that I don't have to replicate my modifications each time.


I know that Android has a built-in Apache HTTP client and URLConnection, but I'm pretty sure that simply packaging my original program in a Jar with a common API won't directly work in Android, will it?


I know I'll get answers like "try it and you'll see", that's actually what I'm about to do. But trying here would cost some time, that's why I'm asking beforehand if there would be a simple way to achieve this before I go into hard translation/integration work. If someone already faced this problem, I could use some insight.


Will I need for instance some sort of wrapper around HTTP-related stuff, which could delegate to Apache on the pure Java program, and to Volley (or anything else) on the Android plateform?


0 comments:

Post a Comment