Spr*_*ngy 2 android android-api-levels
Jelly Bean已经问世,它们有一些相当不错的功能.我的问题是,我希望尽可能多地设备目标,但同时拥有一个可以使用最高API级别的所有功能的应用程序.
所以说例如我有这个
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="16"/>
Run Code Online (Sandbox Code Playgroud)
我在API 16上构建我的应用程序.有没有办法限制代码的某些部分,只有在运行能够运行它的设备时才运行?例如,如果我想要NFC,那么只有姜饼设备及以上才能使用该功能,否则froyo down甚至不会看到该功能.
Basically, you can use many of the new API introduced from Android 3.0 (for example, the Fragment engine), including the Android Support v4 as Referenced Library.
You can find some reference here:
http://developer.android.com/reference/android/support/v4/app/package-summary.html
and here:
http://developer.android.com/tools/extras/support-library.html
By the other hand, if you want use NFC feature for example, you can declare this use-feature:
<uses-feature android:name="android.hardware.nfc" android:required="true" />
Run Code Online (Sandbox Code Playgroud)
or, if you want provide code alternative for devices with no support for this feature, you can do something like that:
if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) {
//code for devices with NFC support
} else {
//code for others devices
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3109 次 |
| 最近记录: |