Reputation: 6182
This is an abstract from the Android docs regarding the targetSDKVersion attribute of the uses-sdk element in the AndroiManifes.xml file.
With this attribute set, the application says that it is able to run on older versions (down to minSdkVersion), but was explicitly tested to work with the version specified here. Specifying this target version allows the platform to disable compatibility settings that are not required for the target version (which may otherwise be turned on in order to maintain forward-compatibility) or enable newer features that are not available to older applications.
Can anyone explain what forward-compatibility means in this context, or come up with examples of "compatibility settings" that can be disabled?
Upvotes: 5
Views: 4480
Reputation: 4041
targetSDKVersion
The version you are compiling against. If you try to use any newer apis you will just get compiler errors, as the compiler won't know what those apis mean.
minSdkVersion
The minimum sdk version you support. Anything device below this won't see or be able to install your app from the market.
Beware, if you use api's from your target sdk that don't exist on lower versions they will compile, but won't work and may crash your app. For this reason you will need to build your code with that in mind.
For example make checks like
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
... Use ice cream sandwich apis ...
to guarantee that users that are before API 14 won't crash.
Edit:
For a list of API changes from version to version go to http://developer.android.com/sdk/index.html
For instance an overview of what is new in the just announced 4.0.3 release: http://developer.android.com/sdk/android-4.0.3.html
And the really gritty details of that release: http://developer.android.com/sdk/api_diff/15/changes.html
Upvotes: 1
Reputation: 5183
You can define a different targetSDKVersion from minSdkVersion, which actually means that you can use the features of the SDK from the targetSDKVersion, while on the same time you have backward compatibility.
This may regard either code parts of your application (for example integrate C2DM to your app and provide your app even to devices with android 2.1 but without the support of C2DM) or in the manifest (i.e. installation option to auto, which will be omitted to android 2.1).
Hope this helps!
Upvotes: 0
Reputation: 18348
This is mainly useful for stating that you support and adapting to big OS jumps, for example, you can design an app that can run from 1.6 to 3.2, without saying the target version is 11+, and it will work, but in API Version 11 and up, you will be runing in compatibility mode, where the tablet will ask you if you want to strech or zoom the app to fit to the screen.
If you set target version to 11, the system will understand that you have actually done something to adapt to that API level, so you will not be presented the option to zoom or strech, instead it just uses it like it would if it were desinged only for 3.0+
Upvotes: 6
Reputation: 8312
Newer android versions always have added features which may not be used in "compatibility mode". I.e. running a device targeted towards 2.2 on a 3.0 android device will run "backward compatibility" features, but if the target is 3.0 and minSdk version 2.2 that will allow installation on 2.2+ devices (with backward compatibility turned on) but also run on the 3.0 version with backward compatibility not turned on (thats what they mean by forward compatibility).
Upvotes: 2