考虑Android向后兼容的几条黄金法则
1.Setting the minSdkVersion —— 设置minSdkVersion值
If the use of a new API is integral to the application — perhaps you need to record video using an API introduced in Android 1.5 (API Level 3) — you should add a <android:minSdkVersion> to the application's manifest, to ensure your app won't be installed on older devices.
2.Using reflection —— 使用反射
3.Using a wrapper class —— 使用包装器
The idea is to create a class that wraps all of the new APIs exposed by a new or existing class. Each method in the wrapper class just calls through to the corresponding real method and returns the same result.
4.Testing is key —— 完备的测试是最关键的
You must test your application on every version of the Android framework that is expected to support it. By definition, the behavior of your application will be different on each. Remember the mantra: if you haven't tried it, it doesn't work.
You can test for backward compatibility by running your application in an emulator that uses an older version of the platform. The Android SDK allows you to do this easily by creating "Android Virtual Devices" with different API levels. Once you create the AVDs, you can test your application with old and new versions of the system, perhaps running them side-by-side to see the differences. More information about emulator AVDs can be found in Creating and Managing Virtual Devices and from emulator -help-virtual-device.
详情请见:http://developer.android.com/resources/articles/backward-compatibility.html
更多相关文章
- android - mvp实现商品详情页面【仿】京东App
- android8.0 反射Application 启动过程
- Android反射工具类ReflectUtil
- Android详情页结合ScrollView完成Title颜色渐变效果
- Android 开发者从0到1发布一个微信小程序的采坑过程——详情页实
- Android 跳转应用市场的应用详情页
- Android的配置文件操作的完美封装(使用注解 反射让配置文件操作如
- Android listview 利用反射的自动绑定Adapter
- Android使用反射机制设置ListView的默认焦点