Using new sdk methods on devices running older sdks?

by Mark Wyszomierski » Tue, 22 Dec 2009 01:27:52 GMT


Sponsored Links
 Hi,

I'm using the level 5 sdk to compile my app, but set my target to sdk
level 3 in my manifest. All is fine.

I may need to use some level 5 classes (ExifInterface) though. What's
the right way to go about using them while not fouling things up for
devices running older sdk versions? Do we simply restrict use of the
newer API methods to completely separate class files? Something like
this:

  // Test.java
  class Test
  {
      public boolean sdkDependentItem() {
          if (Build.VERSION.SDK.equals("5")) {
              return (new sdk5()).getItem();
          }
          else {
              return (new sdk3and4()).getItem();
          }
      }
   }

  // sdk5.java
  class sdk5 {
      public boolean getItem() {
          // can use sdk level 5 apis in here ok.
      }
  }

  // sdk3and4.java
  class sdk3and4 {
      public boolean getItem() {
          // can use sdk level 3 and 4 apis in here ok.
      }
  }

so as long as the api methods are completely separated into files that
the older devices won't invoke, we should be ok?

Thanks

--



Other Threads

1. How to prevent a webview to be reloaded when the screen orientation changes ?





It helps :-) tyvm
--~--~---------~--~----~------------~-------~--~----~

2. HTC Magic - Crippled Features on Retail Devices

The small print, fyi, says google apps may not all be available and that
microsoft owns exchange. Says nothing about exchange not being available, so
in theory if you buy a magic from htc (FROM HTC) you will get exchange sync
but might not get latitude or voice search.









--~--~---------~--~----~------------~-------~--~----~

3. Is cupcake on the UK G1 just plain unreliable?

4. Dailouge box disappears after flipping the device

5. How to prevent a webview to be reloaded when the screen orientation changes ?

6. G1 sales figures?

7. v1.1 included with v1.5 isn't identical to old v1.1?!