2023年全國(guó)碩士研究生考試考研英語(yǔ)一試題真題(含答案詳解+作文范文)_第1頁(yè)
已閱讀1頁(yè),還剩13頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、<p>  Android API Levels</p><p>  As you develop your application on Android, it's useful to understand the platform's general approach to API change management. It's also important to under

2、stand the API Level identifier and the role it plays in ensuring your application's compatibility with devices on which it may be installed.</p><p>  The sections below provide information about API Leve

3、l and how it affects your applications.</p><p>  For information about how to use the "Filter by API Level" control available in the API reference documentation, see Filtering the documentatio

4、n at the end of this document.</p><p>  What is API Level?</p><p>  API Level is an integer value that uniquely identifies the framework API revision offered by a version of the Android pla

5、tform.</p><p>  The Android platform provides a framework API that applications can use to interact with the underlying Android system. The framework API consists of:</p><p>  A core set of pack

6、ages and classes</p><p>  A set of XML elements and attributes for declaring a manifest file</p><p>  A set of XML elements and attributes for declaring and accessing resources</p><p&

7、gt;  A set of Intents</p><p>  A set of permissions that applications can request, as well as permission enforcements included in the system</p><p>  Each successive version of the Android platf

8、orm can include updates to the Android application framework API that it delivers.</p><p>  Updates to the framework API are designed so that the new API remains compatible with earlier versions of the API.

9、That is, most changes in the API are additive and introduce new or replacement functionality. As parts of the API are upgraded, the older replaced parts are deprecated but are not removed, so that existing applications c

10、an still use them. In a very small number of cases, parts of the API may be modified or removed, although typically such changes are only needed to ensure API robust</p><p>  The framework API that an Androi

11、d platform delivers is specified using an integer identifier called "API Level". Each Android platform version supports exactly one API Level, although support is implicit for all earlier API Levels (down to AP

12、I Level 1). The initial release of the Android platform provided API Level 1 and subsequent releases have incremented the API Level.</p><p>  The following table specifies the API Level supported by each ver

13、sion of the Android platform.</p><p>  Uses of API Level in Android</p><p>  The API Level identifier serves a key role in ensuring the best possible experience for users and application develop

14、ers:</p><p>  It lets the Android platform describe the maximum framework API revision that it supports</p><p>  It lets applications describe the framework API revision that they require</p&

15、gt;<p>  It lets the system negotiate the installation of applications on the user's device, such that version-incompatible applications are not installed.</p><p>  Each Android platform version s

16、tores its API Level identifier internally, in the Android system itself.</p><p>  Applications can use a manifest element provided by the framework API — <uses-sdk> — to describe the minimum

17、and maximum API Levels under which they are able to run, as well as the preferred API Level that they are designed to support. The element offers three key attributes:</p><p>  android:minSdkVersion — S

18、pecifies the minimum API Level on which the application is able to run. The default value is "1".</p><p>  android:targetSdkVersion — Specifies the API Level on which the application is design

19、ed to run. In some cases, this allows the application to use manifest elements or behaviors defined in the target API Level, rather than being restricted to using only those defined for the minimum API Level.</p>

20、<p>  android:maxSdkVersion — Specifies the maximum API Level on which the application is able to run. Important: Please read the <uses-sdk> documentation before using this attribute.&

21、lt;/p><p>  For example, to specify the minimum system API Level that an application requires in order to run, the application would include in its manifest a <uses-sdk> element with a andr

22、oid:minSdkVersion attribute. The value of android:minSdkVersion would be the integer corresponding to the API Level of the earliest version of the Android platform under which the application can run.</

23、p><p>  When the user attempts to install an application, or when revalidating an appplication after a system update, the Android system first checks the <uses-sdk> attributes in the application

24、's manifest and compares the values against its own internal API Level. The system allows the installation to begin only if these conditions are met:</p><p>  If a android:minSdkVersion attribu

25、te is declared, its value must be less than or equal to the system's API Level integer. If not declared, the system assumes that the application requires API Level 1.</p><p>  If a android:maxSdkVer

26、sion attribute is declared, its value must be equal to or greater than the system's API Level integer. If not declared, the system assumes that the application has no maximum API Level. Please read the <

27、uses-sdk> documentation for more information about how the system handles this attribute.</p><p>  When declared in an application's manifest, a <uses-sdk> element might look like

28、 this:</p><p>  <manifest>  <uses-sdk android:minSdkVersion="5" />  ...</manifest></p><p>  The principal reason that an application would declare an API

29、 Level in android:minSdkVersion is to tell the Android system that it is using APIs that were introduced in the API Level specified. If the application were to be somehow installed on a platform with

30、a lower API Level, then it would crash at run-time when it tried to access APIs that don't exist. The system prevents such an outcome by not allowing the application to be installed if the lowest API Level it require

31、s is higher than that o</p><p>  For example, the android.appwidget package was introduced with API Level 3. If an application uses that API, it must declare a android:minSdkVersion attri

32、bute with a value of "3". The application will then be installable on platforms such as Android 1.5 (API Level 3) and Android 1.6 (API Level 4), but not on the Android 1.1 (API Level 2) and Android 1.0 platform

33、s (API Level 1).</p><p>  For more information about how to specify an application's API Level requirements, see the <uses-sdk> section of the manifest file documentation.</p><

34、p>  Development Considerations</p><p>  The sections below provide information related to API level that you should consider when developing your application.</p><p>  Application forward com

35、patibility</p><p>  Android applications are generally forward-compatible with new versions of the Android platform.</p><p>  Because almost all changes to the framework API are additive, an And

36、roid application developed using any given version of the API (as specified by its API Level) is forward-compatible with later versions of the Android platform and higher API levels. The application should be able to run

37、 on all later versions of the Android platform, except in isolated cases where the application uses a part of the API that is later removed for some reason.</p><p>  Forward compatibility is important becaus

38、e many Android-powered devices receive over-the-air (OTA) system updates. The user may install your application and use it successfully, then later receive an OTA update to a new version of the Android platform. Once the

39、 update is installed, your application will run in a new run-time version of the environment, but one that has the API and system capabilities that your application depends on.</p><p>  In some cases, change

40、s below the API, such those in the underlying system itself, may affect your application when it is run in the new environment. For that reason it's important for you, as the application developer, to under

41、stand how the application will look and behave in each system environment. To help you test your application on various versions of the Android platform, the Android SDK includes multiple platforms that you can download.

42、 Each platform includes a compatible system image tha</p><p>  Application backward compatibility</p><p>  Android applications are not necessarily backward compatible with versions of the Andro

43、id platform older than the version against which they were compiled.</p><p>  Each new version of the Android platform can include new framework APIs, such as those that give applications access to new platf

44、orm capabilities or replace existing API parts. The new APIs are accessible to applications when running on the new platform and, as mentioned above, also when running on later versions of the platform, as specified by A

45、PI Level. Conversely, because earlier versions of the platform do not include the new APIs, applications that use the new APIs are unable to run on tho</p><p>  Although it's unlikely that an Android-pow

46、ered device would be downgraded to a previous version of the platform, it's important to realize that there are likely to be many devices in the field that run earlier versions of the platform. Even among devices tha

47、t receive OTA updates, some might lag and might not receive an update for a significant amount of time.</p><p>  Selecting a platform version and API Level</p><p>  When you are developing your

48、application, you will need to choose the platform version against which you will compile the application. In general, you should compile your application against the lowest possible version of the platform that your appl

49、ication can support.</p><p>  You can determine the lowest possible platform version by compiling the application against successively lower build targets. After you determine the lowest version, you should

50、create an AVD using the corresponding platform version (and API Level) and fully test your application. Make sure to declare a android:minSdkVersion attribute in the application's manifest and set its value

51、 to the API Level of the platform version.</p><p>  Declaring a minimum API Level</p><p>  If you build an application that uses APIs or system features introduced in the latest platform version

52、, you should set the android:minSdkVersion attribute to the API Level of the latest platform version. This ensures that users will only be able to install your application if their devices are running a compati

53、ble version of the Android platform. In turn, this ensures that your application can function properly on their devices.</p><p>  If your application uses APIs introduced in the latest platform version but d

54、oes not declare a android:minSdkVersion attribute, then it will run properly on devices running the latest version of the platform, but not on devices running earlier versions of the platfor

55、m. In the latter case, the application will crash at runtime when it tries to use APIs that don't exist on the earlier versions.</p><p>  Testing against higher API Levels</p><p>  After com

56、piling your application, you should make sure to test it on the platform specified in the application's android:minSdkVersion attribute. To do so, create an AVD that uses the platform version required by yo

57、ur application. Additionally, to ensure forward-compatibility, you should run and test the application on all platforms that use a higher API Level than that used by your application.</p><p>  The Android SD

58、K includes multiple platform versions that you can use, including the latest version, and provides an updater tool that you can use to download other platform versions as necessary.</p><p>  To access the up

59、dater, use the android command-line tool, located in the <sdk>/tools directory. You can launch the Updater by using the android command without specifying any options. You can also simply double

60、-click the android.bat (Windows) or android (OS X/Linux) file. In ADT, you can also access the updater by selecting Window > Android SDK and AVD Manager.</p><p>  To run your application against

61、 different platform versions in the emulator, create an AVD for each platform version that you want to test. For more information about AVDs, see Creating and Managing Virtual Devices. If you are using a physical de

62、vice for testing, ensure that you know the API Level of the Android platform it runs. See the table at the top of this document for a list of platform versions and their API Levels.</p><p>  Using a Provisio

63、nal API Level</p><p>  In some cases, an "Early Look" Android SDK platform may be available. To let you begin developing on the platform although the APIs may not be final, the platform's API L

64、evel integer will not be specified. You must instead use the platform's provisional API Level in your application manifest, in order to build applications against the platform. A provisional API Level is no

65、t an integer, but a string matching the codename of the unreleased platform version. The provisional API Level will be speci</p><p>  The use of a provisional API Level is designed to protect developers and

66、device users from inadvertently publishing or installing applications based on the Early Look framework API, which may not run properly on actual devices running the final system image.</p><p>  The provisio

67、nal API Level will only be valid while using the Early Look SDK and can only be used to run applications in the emulator. An application using the provisional API Level can never be installed on an Android device. At the

68、 final release of the platform, you must replace any instances of the provisional API Level in your application manifest with the final platform's actual API Level integer.</p><p>  Filtering the Referen

69、ce Documentation by API Level</p><p>  Reference documentation pages on the Android Developers site offer a "Filter by API Level" control in the top-right area of each page. You can use the control

70、 to show documentation only for parts of the API that are actually accessible to your application, based on the API Level that it specifies in the android:minSdkVersion attribute of its manifest file.</p>

71、<p>  To use filtering, select the checkbox to enable filtering, just below the page search box. Then set the "Filter by API Level" control to the same API Level as specified by your application. Notice

72、that APIs introduced in a later API Level are then grayed out and their content is masked, since they would not be accessible to your application.</p><p>  Filtering by API Level in the documentation does no

73、t provide a view of what is new or introduced in each API Level — it simply provides a way to view the entire API associated with a given API Level, while excluding API elements introduced in later API Levels.</p>

74、<p>  If you decide that you don't want to filter the API documentation, just disable the feature using the checkbox. By default, API Level filtering is disabled, so that you can view the full framework API, re

75、gardless of API Level.</p><p>  Also note that the reference documentation for individual API elements specifies the API Level at which each element was introduced. The API Level for packages and classes is

76、specified as "Since <api level>" at the top-right corner of the content area on each documentation page. The API Level for class members is specified in their detailed description headers, at the right ma

77、rgin.</p><p>  Android API級(jí)別</p><p>  當(dāng)你開(kāi)發(fā)你的Android應(yīng)用程序時(shí),了解該平臺(tái)API變更管理的基本方法和概念是很有幫助的。同樣的,知道API級(jí)別標(biāo)識(shí)以及該標(biāo)識(shí)如何保障你的應(yīng)用與實(shí)際硬件設(shè)備相兼容對(duì)于開(kāi)發(fā)及后續(xù)的發(fā)布、維護(hù)都是有益的。</p><p>  本節(jié)內(nèi)容告訴你API級(jí)別的知識(shí),以及它如何影響你開(kāi)發(fā)和使用的應(yīng)用

78、。</p><p>  關(guān)于如何使用“以API級(jí)別進(jìn)行過(guò)濾”來(lái)使用API參考手冊(cè),從本文末尾的文檔過(guò)濾(Filtering the documentation)中可以得到更多信息。</p><p><b>  API級(jí)別是什么?</b></p><p>  API級(jí)別是一個(gè)整數(shù)值,它唯一標(biāo)識(shí)了一個(gè)具體版本的Android平臺(tái),及其框架的API的

79、版本。</p><p>  Android平臺(tái)提供了一套框架API,使得應(yīng)用程序可以與系統(tǒng)底層進(jìn)行交互。該框架API由以下模塊組成:</p><p><b>  一組核心的包和類(lèi)</b></p><p>  清單(manifest)文件的XML元素和屬性聲明</p><p>  資源文件的XML元素和屬性聲明及訪問(wèn)形式&

80、lt;/p><p>  各類(lèi)意圖(Intents)</p><p>  應(yīng)用程序可以請(qǐng)求的各類(lèi)授權(quán),以及系統(tǒng)中包含的授權(quán)執(zhí)行</p><p>  每個(gè)Android平臺(tái)的后續(xù)版本會(huì)包括它提供的更新的Andr??oid應(yīng)用程序框架的API。</p><p>  該框架的API的更新設(shè)計(jì),使高版本的API與早期版本兼容。也就是說(shuō),在新版本API中大多

81、數(shù)都是新增功能,和引進(jìn)新的或替代的功能。作為API的部分升級(jí),老的替換的部分已過(guò)時(shí),但不會(huì)從新版本中刪除,使得已有的應(yīng)用程序仍然可以使用它們。在極少數(shù)情況下,舊版本API的部分可能被修改或刪除,通常這種變化是為了保障API的穩(wěn)定性及應(yīng)用程序或系統(tǒng)的安全。所有其他早期版??本的API將不做修改的保留。</p><p>  一個(gè)Android平臺(tái)提供的框架API,被指定一個(gè)整數(shù)標(biāo)識(shí)符,稱(chēng)為“API級(jí)別”。每一個(gè)版本的

82、Android平臺(tái)只支持有一個(gè)API級(jí)別,雖然該支持是隱含地包括了所有早期的API級(jí)別(一直到API級(jí)別1級(jí))。Andr??oid平臺(tái)的最初版本提供的框架API級(jí)別是1級(jí),隨后的版本依次遞增。</p><p>  下表說(shuō)明了具體平臺(tái)版本和支持的API級(jí)別的對(duì)應(yīng)關(guān)系。</p><p>  在Android中使用API級(jí)別</p><p>  API級(jí)別標(biāo)識(shí)為保證用戶和

83、應(yīng)用程序開(kāi)發(fā)者的最佳體驗(yàn),起了關(guān)鍵作用:</p><p>  它讓Android平臺(tái)可以描述它支持的框架API的最高版本</p><p>  它讓?xiě)?yīng)用程序可以描述它需要的框架API版本</p><p>  它使得系統(tǒng)可以在硬件設(shè)備上安裝應(yīng)用程序時(shí)能夠檢查版本是否匹配,使得版本不兼容的應(yīng)用程序不會(huì)被錯(cuò)誤安裝在設(shè)備之上.</p><p>  每個(gè)

84、版本的Android平臺(tái)都在其內(nèi)部存儲(chǔ)了自己的API級(jí)別標(biāo)識(shí)。</p><p>  應(yīng)用程序可以用框架API提供的清單文件元素 — <uses-sdk> 來(lái)描述該應(yīng)用程序可以運(yùn)行的最小和最大API級(jí)別,以及應(yīng)用程序開(kāi)發(fā)者設(shè)計(jì)期望運(yùn)行的平臺(tái)版本。三種屬性分別描述如下:</p><p>  android:minSdkVersion —

85、60;指明該應(yīng)用程序可以運(yùn)行的API最低版本。默認(rèn)是“1”。</p><p>  android:targetSdkVersion — 指明該應(yīng)用程序設(shè)計(jì)時(shí)期望運(yùn)行的目標(biāo)API版本。在某些情況下,這允許應(yīng)用程序使用目標(biāo)API級(jí)別下定義的清單元素或行為,而不是只限于使用最低API級(jí)別定義的內(nèi)容。</p><p>  android:maxSdkVersion —

86、 指明該應(yīng)用程序可以運(yùn)行的最高API級(jí)別。重要聲明: 使用該屬性之前請(qǐng)閱讀<uses-sdk>文檔。</p><p>  比如,要指明一個(gè)應(yīng)用程序能夠運(yùn)行的最低API級(jí)別,應(yīng)當(dāng)在該應(yīng)用程序的清單文件的<uses-sdk>元素中加入android:minSdkVersion屬性。android:minSdkVersion的值是一個(gè)正整數(shù),對(duì)應(yīng)的是該應(yīng)用程序能夠運(yùn)行的最低平

87、臺(tái)的API級(jí)別標(biāo)識(shí)。</p><p>  用戶嘗試安裝一個(gè)應(yīng)用程序,或者在系統(tǒng)升級(jí)后重驗(yàn)證應(yīng)用程序的時(shí)候,Android系統(tǒng)首先會(huì)檢查應(yīng)用程序的清單文件中的<uses-sdk>屬性,將其與系統(tǒng)內(nèi)部API級(jí)別對(duì)比。系統(tǒng)只有在滿足下列情況時(shí)才允許進(jìn)行應(yīng)用程序安裝:</p><p>  如果聲明了android:minSdkVersion屬性,其屬性值必須小于或等于該系統(tǒng)的API級(jí)別

88、對(duì)應(yīng)的整數(shù)值。如果未聲明,系統(tǒng)會(huì)默認(rèn)該應(yīng)用程序運(yùn)行需要的最低API級(jí)別是1。</p><p>  如果聲明了android:maxSdkVersion屬性,其屬性值必須等于或大于該系統(tǒng)的API級(jí)對(duì)應(yīng)的整數(shù)值。如果未聲明,系統(tǒng)會(huì)默認(rèn)該應(yīng)用程序沒(méi)有最高API級(jí)別限制。請(qǐng)通過(guò)閱讀文檔<uses-sdk>以獲得系統(tǒng)如何處理該屬性的更多信息。</p><p>  應(yīng)用程序清單文件中聲明該

89、屬性后, <uses-sdk>元素看起來(lái)應(yīng)類(lèi)似于下面的例子:</p><p>  <manifest>  <uses-sdk android:minSdkVersion="5" />  ...</manifest></p><p>  這樣做的主要原因是,應(yīng)用程序會(huì)通過(guò)android:m

90、iniSdkVersion聲明的API級(jí)別來(lái)告知系統(tǒng)——該應(yīng)用程序使用的API是指定引入的API級(jí)別。假如沒(méi)有這種屬性聲明,一個(gè)應(yīng)用程序如果因?yàn)槟承┎恢脑虮话惭b在低級(jí)別API系統(tǒng)之上,那么該應(yīng)用程序會(huì)在運(yùn)行時(shí)因?yàn)閲L試訪問(wèn)不存在的API而崩潰。為此,Android系統(tǒng)通過(guò)不允許應(yīng)用程序被安裝在不滿足其最低API級(jí)別要求的目標(biāo)硬件上來(lái)防止此類(lèi)結(jié)果發(fā)生。</p><p>  例如,android.appwidge

91、t類(lèi)包是在API級(jí)別3中開(kāi)始引入的。如果一個(gè)應(yīng)用程序使用了這個(gè)API,就必須通過(guò)指明android:minSdkVersion屬性為3來(lái)聲明運(yùn)行的最低要求。于是,該應(yīng)用程序就可以在Android 1.5(API級(jí)別3級(jí))、Android 1.6 (API級(jí)別4級(jí))等平臺(tái)上安裝,但是在Android 1.1 (API級(jí)別2級(jí))和 Android 1.0 平臺(tái)(API級(jí)別1級(jí))上卻是無(wú)法安裝的。</p>&

92、lt;p>  欲知關(guān)于如何聲明應(yīng)用程序API級(jí)別需求的更多信息,請(qǐng)閱讀文檔中關(guān)于清單文件的<uses-sdk>章節(jié)。</p><p>  開(kāi)發(fā)者需要考慮的內(nèi)容</p><p>  本節(jié)屬于應(yīng)用程序開(kāi)發(fā)者需要了解的內(nèi)容。</p><p>  應(yīng)用程序的向前兼容性</p><p>  Android應(yīng)用程序一般向前兼容于Andr

93、oid平臺(tái)的新版本。</p><p>  這是因?yàn)閹缀跛械目蚣蹵PI變更都是添加性質(zhì)的,一個(gè)以某種版本的API開(kāi)發(fā)的應(yīng)用程序是向前兼容與后續(xù)Android系統(tǒng)及高版本API。應(yīng)用程序應(yīng)當(dāng)可以運(yùn)行于高版本的平臺(tái),除非使用了未來(lái)因某種原因移除的API。</p><p>  向前兼容性的特性如此重要,是因?yàn)楹芏嗟腁ndroid驅(qū)動(dòng)的設(shè)備能夠使用OTA遠(yuǎn)程下載技術(shù)進(jìn)行系統(tǒng)更新。用戶開(kāi)始時(shí)能夠很好

94、的安裝和使用你開(kāi)發(fā)的應(yīng)用程序,后來(lái)進(jìn)行了OTA升級(jí)到新版本的Android平臺(tái)。一旦升級(jí)完畢,你的應(yīng)用程序?qū)⑦\(yùn)行在一個(gè)新的版本環(huán)境下,而這個(gè)環(huán)境應(yīng)當(dāng)包含了你的應(yīng)用程序所需的API和系統(tǒng)功能。</p><p>  某些情況下,API背后的變化,例如系統(tǒng)底層的變化,可能會(huì)影響到你的應(yīng)用程序運(yùn)行在新的環(huán)境下。為此,作為應(yīng)用程序開(kāi)發(fā)人員,應(yīng)當(dāng)了解應(yīng)用程序在不同系統(tǒng)環(huán)境下將會(huì)有如何的外觀和行為。Android SDK包含了

95、多個(gè)平臺(tái)版本,開(kāi)發(fā)人員可以下載下來(lái),用于測(cè)試自己的應(yīng)用程序在不同版本下的運(yùn)行情況。每個(gè)版本的平臺(tái)都提供了兼容的系統(tǒng)鏡像,你可以將應(yīng)用程序運(yùn)行在對(duì)應(yīng)的Android虛擬設(shè)備(模擬器)上進(jìn)行測(cè)試。</p><p>  應(yīng)用程序的向后兼容性</p><p>  Android應(yīng)用程序不一定向后兼容于那些比這些應(yīng)用程序開(kāi)發(fā)環(huán)境低的平臺(tái)環(huán)境。</p><p>  Androi

96、d平臺(tái)的每個(gè)新版本包含了新的框架API,例如新的平臺(tái)功能,或者替代部分已有的API。應(yīng)用程序在新平臺(tái)上可以訪問(wèn)這些新的API,就像之前提到的,在后續(xù)更新的版本中,這些新功能API也是可以繼續(xù)使用。相反的,因?yàn)樵缙诎姹镜钠脚_(tái)不會(huì)包含新的API功能,使用了新API的應(yīng)用程序在那些舊平臺(tái)上是無(wú)法運(yùn)行的。</p><p>  雖然一個(gè)Android平臺(tái)設(shè)備不太可能降級(jí)到以前的版本,但是需要了解的是:實(shí)際生活中可能會(huì)有很多

97、設(shè)備運(yùn)行的是較舊的平臺(tái)版本。即使在設(shè)備接收到OTA遠(yuǎn)程下載升級(jí),有些人仍然可能會(huì)滯后甚至可能不會(huì)收到更新。</p><p>  平臺(tái)版本和API級(jí)別的選擇</p><p>  當(dāng)你開(kāi)發(fā)應(yīng)用程序時(shí),你需要選擇一個(gè)平臺(tái)用于編譯該應(yīng)用程序。通常,你應(yīng)該在你的應(yīng)用程序可以支持的最低版本的平臺(tái)上進(jìn)行編譯。</p><p>  你可以通過(guò)尋找最低的可以支持你的應(yīng)用程序編譯的平臺(tái)

98、方式來(lái)決定你將會(huì)支持的最低平臺(tái)版本。一旦你確定了支持的最低版本后,你就可以創(chuàng)建對(duì)應(yīng)版本的AVD模擬器來(lái)全面測(cè)試你的應(yīng)用程序。你需要注意的是不要忘記在應(yīng)用程序清單文件中申明android:minSdkVersion屬性,并賦上正確的API級(jí)別標(biāo)識(shí)。</p><p><b>  聲明最低API級(jí)別</b></p><p>  如果你開(kāi)發(fā)的應(yīng)用程序使用了最新平臺(tái)上引入的AP

99、I或平臺(tái)特性,你就需要將android:minSdkVersion屬性賦最新平臺(tái)的API級(jí)別標(biāo)識(shí)。這將保證用戶只能在他們的設(shè)備與你的應(yīng)用程序平臺(tái)版本兼容情況下安裝。反過(guò)來(lái)說(shuō),這樣能夠保證你的應(yīng)用程序在他們的設(shè)備上表現(xiàn)正常。</p><p>  如果你用了最新的API或平臺(tái)特性,但是沒(méi)有申明android:minSdkVersion屬性,那么你的應(yīng)用程序在最新平臺(tái)上運(yùn)行是沒(méi)有穩(wěn)定,但是在早期版本的平臺(tái)上是會(huì)出錯(cuò)的。

100、在后一種情況,應(yīng)用程序在嘗試訪問(wèn)舊平臺(tái)上不存在的API時(shí)會(huì)崩潰。</p><p>  針對(duì)高版本的API級(jí)別測(cè)試</p><p>  編譯完你的應(yīng)用程序,你應(yīng)當(dāng)在支持的最低版本平臺(tái)上詳細(xì)測(cè)試應(yīng)用程序的表現(xiàn)??梢酝ㄟ^(guò)創(chuàng)建對(duì)應(yīng)平臺(tái)的AVD模擬器進(jìn)行測(cè)試。此外,要保證向前兼容性,你應(yīng)當(dāng)在你的應(yīng)用程序可能運(yùn)行的更高平臺(tái)版本上進(jìn)行運(yùn)行和測(cè)試。</p><p>  Androi

101、d SDK包含了多個(gè)平臺(tái)版本供開(kāi)發(fā)者使用,其中包括了最新的版本,并且提供了升級(jí)工具使得開(kāi)發(fā)者可以獲取其他的版本。</p><p>  要使用升級(jí)工具,可以通過(guò)Android命令行方式,該工具位于<sdk>/tools路徑下。你可以用敲入android指令運(yùn)行該升級(jí)工具,而不用指定任何參數(shù)。你也可以簡(jiǎn)單地通過(guò)雙擊Windows下的android.bat或OS X/Linux下的android文件來(lái)啟動(dòng)升

102、級(jí)工具。在ADT工具界面,你可以通過(guò)菜單的Window > Android SDK and AVD Manager來(lái)訪問(wèn)升級(jí)工具。</p><p>  要想將你的應(yīng)用程序在不同平臺(tái)版本的模擬器上運(yùn)行,需要?jiǎng)?chuàng)建對(duì)應(yīng)的AVD設(shè)備。關(guān)于AVD的更多信息,請(qǐng)參見(jiàn)Creating and Managing Virtual Devices。如果你用物理設(shè)備進(jìn)行測(cè)試,確保清楚運(yùn)行的具體平臺(tái)版本。通過(guò)本

103、文開(kāi)始部分的映射表格可以知道平臺(tái)版本對(duì)應(yīng)的API級(jí)別標(biāo)識(shí)。</p><p>  使用臨時(shí)的API級(jí)別</p><p>  某些情況下,有可能會(huì)發(fā)布“早期預(yù)覽(Early Look)”版的Android 平臺(tái)SDK。在此平臺(tái)版本上開(kāi)發(fā)使用的API將不會(huì)是最終發(fā)布版,平臺(tái)的API級(jí)別標(biāo)識(shí)數(shù)字就不會(huì)指定。你必須在程序清單文件中使用臨時(shí)的API級(jí)別進(jìn)行標(biāo)識(shí),以便建立對(duì)應(yīng)的平臺(tái)應(yīng)用。臨時(shí)A

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 眾賞文庫(kù)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論