Support multiple sdk-version in one release (Android or others Java based platform)

Hi,

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

 

Advertisements

1 Comment

  1. vd11

    you…you’re alive ?? it’s incredible !! 😉
    So what’s up man ?? you work on android now ? Give news, it will be nice 🙂
    a bientot mec

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: