I haven't tried using a deprecated class in 1.6 - is it marked as deprecated, and the compiler refuses to process it? There is a compiler flag for that. Or is it gone completely?
You need to consider the way the JVM works. The class manager will not load a class until it is referenced (in ANY way - you create an instance of that class, or you access a static variable or method). As soon as that happens, the class loader will initialize that class and resolve EVERY method and referenced class in it, so as soon as you reference class Foo which has a 1.6-specific method in it, your app will crash under 1.5. You can still put all your 1.6-specific code into one class, and stay away from it with a 10-foot-pole if you detect that you can't use it (the proper way would be to try to resolve the 1.6 methods it uses via reflection in your main class, and if that fails, never use the 1.6 class). -Mike On Oct 9, 7:09 am, Greivin Lopez <[email protected]> wrote: > I have a question related to backward compatibility in Android. My > applications uses SmsManager class that was deprecated in SDK 1.5 and > moved to other package in SDK 1.6 to support CDMA. That's OK. > > The problem is I want to support 1.5 SDK and also being able to use > the new SmsManager class. I think the only way to do that is using the > solution suggested by EboMike (with reflection), but I think is more a > patch than the correct way around. Other solution could be to compile > the code to the desire target and keep two different releases of the > application but I don't like the idea to maintain two versions of my > code. > > I think a must elegant design for this is to use some sort of compiler > directives that let us developers to differentiate parts of our code > associated to one version of the SDK or another one, but I don't see > anything in Android to accomplish that. > > Is there a way to achieve this? I suppose there isn't but maybe > someone could share some new ideas on this scenario. I would > appreciate any help. Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

