The usual way to achieve that is to take advantage of the fact that Java won't load a class until it's first needed. Wrap up code that calls API functions that might not always be there (the getSupportedVideoSizes() call in your example) in a class which only gets instantiated if deviceLevel >= 11. On top of that, you'll need to build against a version >= 11 (in Eclipse, set your Project Build Target to >= 11) so that your new wrapper class doesn't give you compile errors.
On Tue, May 7, 2013 at 2:09 AM, Linda Li <[email protected]>wrote: > How can I do that? > > > I want to develop an Android application even for android devices with a > lower version, while I do not want to sacrifice some available functions in > higher versions. > > > In the AndroidManifest.xml file: > > <uses-sdk > > android:minSdkVersion="8" > > android:targetSdkVersion="17" /> > > > I get the android level of the current device: > > deviceLevel = android.os.Build.VERSION.SDK_INT; > > > Then I will use if statements to specify different code for different > versions. > > if (deviceLevel >= 11) > > { > > List<Camera.Size> videoSizes = parameters > > .getSupportedVideoSizes(); > > ...... > > } > > else > > { > > ...... > > } > > > However, Eclipse indicates there exists errors. getSupportedVideoSizes > is not availabe for version = 8; > > > I think I need to suppress the error at this situation. > > How to do that? > > -- > -- > 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 > --- > You received this message because you are subscribed to the Google Groups > "Android Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- -- 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 --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

