So I have a API issue. So i am creating a class that utilizes AndroidHttpClient to download Bitmap images from my server. Problem is, its API Level is 8 and I want this to be used from API 1 and above. Now I know I can use DefaultHttpClient (the API is Level 1) but is there a way I can use both, being distinguished by Build.VERSION.SDK (btw thanx for the quick respose, Konstantin Burov and iandisme).
So for example, if my device is 2.2 I use AndroidHttpClient, anything else use DefaultHttpClient.
Of course if I import the library it will give me an error on any device 1.5 to 2.1.
Any suggestions would greatly be appreciated, because in the future I would want to set other preferences based on API.
I would do this by having two classes, each implementing an
interfacewith the methods you need. Let’s call theinterface BitmapDownloader, and the two classesDownloader1andDownloader2(I know the class names suck but I’m not feeling terribly creative).Downloader1willimportand use the old libraries, andDownloader2willimportand use the new ones. Your code would look something like this: