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_dev&message.id=17826 (with two Blackberry OS versions, for which the factory method did not seem to work either) I want to avoid doing two compilations (with two SDK's, which would create a future maintenance headache).
Regards On Apr 15, 8:54 am, Tom Gibara <[email protected]> wrote: > 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 hold > onto a reference to the appropriate implementation and avoid repeatedly > checking the version number. > It does add the cost of a interface method call, but that's perfectly > acceptable in most instances - if not, it's usually because the work is > being done in an inner loop, in that case you generally need to replicate > the loop for both implementations. > > Tom. > > 2009/4/15 Pieter <[email protected]> > > > > > 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 received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

