I’m building an App for Android, but I’d like to make it so I can use 4.0.3 features as a minimum. I’m not worried currently about releasing this for those who use 4.0 and below.
Basically, my questions are as follows:
-
If I already have a project with a base minimum SDK in Eclipse set to 4.0.3, with the max set to the same, can I change the maximum? If so, how?
-
Are 4.0.3 apps compatible with 4.1 apps at all? If not, what’s a good work around for this? If I were doing this in C/C++ the answer would be a preprocessor directive (e.g.,
#ifdef ANDROID_OS_4_1 //do stuff for 4.1 only #endif). I know of no such equivalent in Java, however, let alone for Android.
To build against JellyBean, you can use the
<uses-sdk />tag in your AndroidManifest (just above your<application />tag):By using a targetSdkVersion of 16 (JellyBean) you get access to all the new API’s
At runtime you can then check what version of Android the app is running on and perform actions based off that. I use a utility class in my apps to do this:
Then in your code you can do things like: