Support multiple sdk-version in one release (Android or others Java based platform)
I just think it’s could be useful to share the new java notion I just learned to fix the study case below:
how to handle multiple sdk version in one release on Android?
I’m building a camera app right now for my company, then I want to handle front and back camera, and others camera capacities which could not be available on the current SDK.
So how could I make my right import without crashing the VM?
Very simple answer here:
Static classes are not loaded by the VM until one his method is called.
So what you need to do is implement a singleton pattern, through an abstract class, which will choose the static class to call. So graceful right?
You can find an implementation example here: http://devtcg.blogspot.com/2009/12/gracefully-supporting-multiple-android.html
Find real and full explanation on wiki here: http://en.wikipedia.org/wiki/Initialization_on_demand_holder_idiom