Wednesday, July 28, 2010

Supporting Multiple Android Version

Previously when considering new features for CedIME, I always hesitate about features that require a newer Android version like Voice Input. I want to support devices back to Android 1.5. And I thought it was tedious to manually support multiple code base for different versions of Android.

Now the smart people at Google has shown us the way! Using a method developed by Bill Pugh that was originally developed for implementing a lazy Singleton pattern in Java. It can be modified slightly to accomplish the magic of selecting the right class to load for different runtime versions of Android.

This is much better than using reflection which is slow and ugly.

Using this method I've already made CedIME support multitouch as the Froyo keyboard on Android version 2.0 or above, which is coming in CedIME 1.2.0 together with some other Froyo keyboard features. Stay tuned.

No comments: