Monday, December 21, 2009

[android-developers] Using new sdk methods on devices running older sdks?

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

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate