13.04.2011 13:06, Marcin Orlowski пишет:

This is normal, unfortunately. If you use something from API 11, building against 4 will throw errors as such method/constant etc simply does not exist in API 4. That's why I said you shall build against highest API you use features of due to that. Kostya most likely got different case as he checks if he is not (unintentionally) using something that does not exists in lower API.

Yes. You can't directly call a class or method that doesn't exist in the SDK you're building with. Doing this requires the use of Java reflection.

So there are two ways really:

- Build against the highest SDK version, create wrapper classes for higher / lower API versions, switch them at runtime depending on the actual device API level.

- Build against the lowest SDK version, use Java reflection to access higher API methods.

However, if you're going to use any higher features in the manifest, you have to build with that higher version. There is no reflection for the manifest.


Yes, you shall pay more attention to testing if your app does what you say it do, because there's higher risk of facing bug or problems caused by this conditional code.

+100500 to testing :)

Compiling against the lower version is a good quick sanity check.

--
Kostya Vasilyev -- http://kmansoft.wordpress.com

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

Reply via email to