我想使用Android SDK和Eclipse编写一个应用程序。
我使用SDK管理器安装了Android 4平台,但我想知道,这个应用程序只能在Android 4设备上运行吗?还是可以在Android 2设备上运行?
谢谢。
我想使用Android SDK和Eclipse编写一个应用程序。
我使用SDK管理器安装了Android 4平台,但我想知道,这个应用程序只能在Android 4设备上运行吗?还是可以在Android 2设备上运行?
谢谢。
这取决于您所使用的系统调用。一定要在运行不同版本的设备上进行测试,因为某些调用仅适用于特定的API级别。
您可以在SDK网站上查看此信息。
(请参见getNumberOfCameras函数灰色条的右侧“Since: API Level 9”)
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="15" />
当然,您必须仅使用可用的较低SDK功能。您还应该查看Google支持库,该支持库为旧版SDK提供了一些新功能。
http://developer.android.com/tools/extras/support-library.html
// Marcello
Android Lint是ADT r16引入的新工具,它会自动扫描和检查您的项目中是否使用了新的API,并在Eclipse编辑器中显示错误标记。
有关检查新API的规则,请参见此处:
NewApi
------
Summary: Finds API accesses to APIs that are not supported in all targeted API
versions
Priority: 6 / 10
Severity: Error
Category: Correctness
This check scans through all the Android API calls in the application and
warns about any calls that are not available on *all* versions targeted by
this application (according to its minimum SDK attribute in the manifest).
If your code is *deliberately* accessing newer APIs, and you have ensured
(e.g. with conditional execution) that this code will only ever be called on a
supported platform, then you can annotate your class or method with the
@TargetApi annotation specifying the local minimum SDK to apply, such
as@TargetApi(11), such that this check considers 11 rather than your manifest
file's minimum SDK as the required API level.