[android-developers] Re: Use SDK 1.5 features while maintaining SDK 1.0,1.1 backward compatibility

2009-04-15 Thread Pieter
If the amount of 1.5 code is small, you can use reflection to make the calls in order to fool the verifier. This quickly becomes a pain in the butt when you have to call more than a few 1.5 methods or work with multiple 1.5 objects though. --~--~-~--~~~---~--~~ You

[android-developers] Re: Use SDK 1.5 features while maintaining SDK 1.0,1.1 backward compatibility

2009-04-15 Thread Tom Gibara
A more straightforward approach that should work is to isolate the affected code behind an interface, with separate implementations for 1.1 and 1.5. A factory method can be used to opaquely return the correct instance based on the build's sdk version. This has the advantage that you can usually

[android-developers] Re: Use SDK 1.5 features while maintaining SDK 1.0,1.1 backward compatibility

2009-04-15 Thread blindfold
Thanks Tom and Pieter. I haven't tried your suggestions yet, but is there any guarantee that the phone's VM will not also verify isolated classes or methods? By analogy to http://supportforums.blackberry.com/rim/board/message?board.id=java_devmessage.id=17826 (with two Blackberry OS versions, for

[android-developers] Re: Use SDK 1.5 features while maintaining SDK 1.0,1.1 backward compatibility

2009-04-15 Thread Tom Gibara
The JLS requires that, even if a JVM identifies a binding error early, the exception raised must be deferred until an attempt is made to use the class. I'm paraphrasing here, but it's been years since I last read the JLS. That's the basic idea anyway. Of course, the interface can only depend on

[android-developers] Re: Use SDK 1.5 features while maintaining SDK 1.0,1.1 backward compatibility

2009-04-15 Thread blindfold
Indeed it works! Thanks a lot, Tom. My app containing new SDK 1.5 API calls now runs fine on my SDK 1.1 developer phone. You were absolutely right, and this solution is elegant from a future maintenance point of view. Much appreciated! On Apr 15, 12:55 pm, Tom Gibara m...@tomgibara.com wrote:

[android-developers] Re: Use SDK 1.5 features while maintaining SDK 1.0,1.1 backward compatibility

2009-04-14 Thread Xavier Le Vourch
blindfold wrote: Hi, I want to avoid the SDK 1.0 and 1.1 workaround for playing synthesized audio as of SDK1.5, but for older phones or firmware (SDK 1.0 and 1.1 based) I want to maintain backward compatibility and first write audio to flash memory in order to play the resulting audio file

[android-developers] Re: Use SDK 1.5 features while maintaining SDK 1.0,1.1 backward compatibility

2009-04-14 Thread blindfold
Thanks, good to know. Still I now find that if I compile my app for SDK 1.5 but without using any 1.5 features, I can next run my app on my DP1.1 (SDK 1.1), but just having code with 1.5 features in a branch that is never reached causes a java.lang.VerifyError when trying to run on my DP1.1. So