Many times in Android , you see that a method is deprecated as of version 3.0 and a different method should be used.
How do you handle such things when programming your app if you are targeting most of the devices (say from Version 2.1). Do you code the same app multiple times each one for different version? and then create different profiles in Google Play for each APK? I find it this a bit excessive and does not make sense. Please let me know what is the correct way of handling such situations
Thanks
the easiest approach would be to simply check what version your app is running on act accordingly. I.e.
You can find all version codes here. Remember you need to build your app with
targetSdkset to latest possible. This is however risky as you can easily use method not available on older platforms and your application would crash as compiler won’t warn you. To mitigate this it usually helps to pay attention what are you using 🙂 but also to wrap such “risky” code into library or utility class so you can be sure no other code of yours does that trickery by itself. It also helps to set API filter on documentation at http://d.android.com/ (these small up/down arrows on left titlebar, next to “Android APIs) to LOWEST version you plan to support. In case it is something not used often, there’s a chance you peek there catch the risk “visually”
There’s also plugin for Eclipse that does such checks, but I do not use it myself and cannot remember its name at the moment.