• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Code for Multiple API's

How do you write code that can enable features provided in a newer API and ignore the code if the feature is not available.

An example is cameraInfo.canDisableShutterSound which is provided in API level 17.

try {
canDisable = cameraInfo.canDisableShutterSound;
} catch (Exception e) {
canDisable = false;
Log.e(TAG,
getClass().getName() + "."
+ e.getStackTrace()[0].getMethodName()
+ " error:", e);
}

I would like the code to be used if the API is 17 or greater and ignored if the API is less than 17.

Thank you.

Richard Maley
 
Back
Top Bottom