is it possible to set the Minumum SDK and target SDK versions in code for an Android Application? Normally this is specified in the Manifest.xml file
2 Answers
No it is not, the system should be able to read it before it runs your application.
When preparing to install your application, the system checks the value of this attribute and compares it to the system version. If the android:minSdkVersion value is greater than the system version, the system aborts the installation of the application. Similarly, the system installs your application only if its android:maxSdkVersion is compatible with the platform version.
If you do not specify these attributes in your manifest, the system assumes that your application is compatible with all platform versions, with no maximum API Level.