如何最好地应对不同的Andr​​oid版本? [英] how best to cope with different versions of Android?

查看:102
本文介绍了如何最好地应对不同的Andr​​oid版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序工作正常,在安卓1.x中,但不是在安卓2.X 我需要基于Android的应用程序是在(查询联系人)运行的版本做的事情不同。 是有可能有,我可以选择基于Android的版本,一个应用程序中的两个不同的方法的应用程序正在运行呢?

I have an app that works fine in Android 1.x but not in Android 2.x i need to do things different based on the version of Android the app is running on (querying contacts). is it possible to have two separate methods within the one app that i can choose based on the version of Android the app is running on?

非常感谢

推荐答案

使用反射和类加载器。看到这个帖子上的Andr​​oid开发者博客:<一href="http://feedproxy.google.com/~r/blogspot/hsDu/~3/9WEwRp2NWlY/how-to-have-your-cupcake-and-eat-it-too.html" rel="nofollow">http://feedproxy.google.com/~r/blogspot/hsDu/~3/9WEwRp2NWlY/how-to-have-your-cupcake-and-eat-it-too.html

Use reflection and class loaders. See this post on the Android developers blog: http://feedproxy.google.com/~r/blogspot/hsDu/~3/9WEwRp2NWlY/how-to-have-your-cupcake-and-eat-it-too.html

编辑: 感谢CommonsWare的指出它同时使用新的和旧的通讯录内容提供商和条件的类加载一个示例项目:的 http://github.com/commonsguy/cw-advandroid/tree/master/Contacts/Spinners/

Thanks to CommonsWare for pointing out a sample project which uses both the new and old contacts content providers and conditional class loading: http://github.com/commonsguy/cw-advandroid/tree/master/Contacts/Spinners/

这篇关于如何最好地应对不同的Andr​​oid版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆