安卓 英文 外文文獻(xiàn)翻譯 Android API級別_第1頁
安卓 英文 外文文獻(xiàn)翻譯 Android API級別_第2頁
安卓 英文 外文文獻(xiàn)翻譯 Android API級別_第3頁
安卓 英文 外文文獻(xiàn)翻譯 Android API級別_第4頁
安卓 英文 外文文獻(xiàn)翻譯 Android API級別_第5頁
已閱讀5頁,還剩8頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

N尊*理工大修GuilinUniversityofTechnology本科畢業(yè)設(shè)計(jì)(論文)夕卜文翻譯(附外文原文)學(xué)院: 信息科學(xué)與工程學(xué)院課題名稱:基于騰訊微博開放平臺的數(shù)字教學(xué)交流系統(tǒng)專業(yè)(方向):計(jì)算機(jī)科學(xué)與技術(shù)班級:BCU09-4學(xué) 生:周杰倫指導(dǎo)教師:方文山日 期: 2013/4/19AndroidAPI級別當(dāng)你開發(fā)你的Android應(yīng)用程序時(shí),了解該平臺API變更管理的基本方法和概念是很有幫助的。同樣的,知道API級別標(biāo)識以及該標(biāo)識如何保障你的應(yīng)用與實(shí)際硬件設(shè)備相兼容對于開發(fā)及后續(xù)的發(fā)布、維護(hù)都是有益的。本節(jié)內(nèi)容告訴你API級別的知識,以及它如何影響你開發(fā)和使用的應(yīng)用。關(guān)于如何使用“以API級別進(jìn)行過濾〃來使用API參考手冊,從本文末尾的文檔過濾(Filteringthedocumentation)中可以得到更多信息。API級別是什么?API級別是一個(gè)整數(shù)值,它唯一標(biāo)識了一個(gè)具體版本的Android平臺,及其框架的API的版本。Android平臺提供了一套框架API,使得應(yīng)用程序可以與系統(tǒng)底層進(jìn)行交互。該框架API由以下模塊組成:一組核心的包和類清單(manifest)文件的XML元素和屬性聲明資源文件的XML元素和屬性聲明及訪問形式各類意圖(Intents)應(yīng)用程序可以請求的各類授權(quán),以及系統(tǒng)中包含的授權(quán)執(zhí)行每個(gè)Android平臺的后續(xù)版本會包括它提供的更新的Android應(yīng)用程序框架的API。該框架的API的更新設(shè)計(jì),使高版本的API與早期版本兼容。也就是說,在新版本API中大多數(shù)都是新增功能,和引進(jìn)新的或替代的功能。作為API的部分升級,老的替換的部分已過時(shí),但不會從新版本中刪除,使得已有的應(yīng)用程序仍然可以使用它們。在極少數(shù)情況下,舊版本API的部分可能被修改或刪除,通常這種變化是為了保障API的穩(wěn)定性及應(yīng)用程序或系統(tǒng)的安全。所有其他早期版本的API將不做修改的保留。一個(gè)Android平臺提供的框架API,被指定一個(gè)整數(shù)標(biāo)識符,稱為“API級別〃。每一個(gè)版本的Android平臺只支持有一個(gè)API級別,雖然該支持是隱含地包括了所有早期的API級別(一直到API級別1級)。Android平臺的最初版本提供的框架API級別是1級,隨后的版本依次遞增。下表說明了具體平臺版本和支持的API級別的對應(yīng)關(guān)系。平臺版本API級別Android3.011Android2.3.310Android2.39Android2.28Android2.17Android2.0.16Android2.05Android1.64Android1.53Android1.12Android1.01在Android中使用API級別API級別標(biāo)識為保證用戶和應(yīng)用程序開發(fā)者的最佳體驗(yàn),起了關(guān)鍵作用:它讓Android平臺可以描述它支持的框架API的最高版本它讓應(yīng)用程序可以描述它需要的框架API版本它使得系統(tǒng)可以在硬件設(shè)備上安裝應(yīng)用程序時(shí)能夠檢查版本是否匹配,使得版本不兼容的應(yīng)用程序不會被錯(cuò)誤安裝在設(shè)備之上.每個(gè)版本的Android平臺都在其內(nèi)部存儲了自己的API級別標(biāo)識。應(yīng)用程序可以用框架API提供的清單文件元素一<uses-sdk>來描述該應(yīng)用程序可以運(yùn)行的最小和最大API級別,以及應(yīng)用程序開發(fā)者設(shè)計(jì)期望運(yùn)行的平臺版本。三種屬性分別描述如下:android:minSdkVersion—指明該應(yīng)用程序可以運(yùn)行的API最低版本。默認(rèn)是''1"。android:targetSdkVersion—指明該應(yīng)用程序設(shè)計(jì)時(shí)期望運(yùn)行的目標(biāo)API版本。在某些情況下,這允許應(yīng)用程序使用目標(biāo)API級別下定義的清單元素或行為,而不是只限于使用最低API級別定義的內(nèi)容。android:maxSdkVersion—指明該應(yīng)用程序可以運(yùn)行的最高API級別。重要聲明:使用該屬性之前請閱讀<uses-sdk>文檔。比如,要指明一個(gè)應(yīng)用程序能夠運(yùn)行的最低API級別,應(yīng)當(dāng)在該應(yīng)用程序的清單文件的<uses-sdk>元素中加入android:minSdkVersion屬性。android:minSdkVersion的值是一個(gè)正整數(shù),對應(yīng)的是該應(yīng)用程序能夠運(yùn)行的最低平臺的API級別標(biāo)識。用戶嘗試安裝一個(gè)應(yīng)用程序,或者在系統(tǒng)升級后重驗(yàn)證應(yīng)用程序的時(shí)候,Android系統(tǒng)首先會檢查應(yīng)用程序的清單文件中的<uses-sdk>屬性,將其與系統(tǒng)內(nèi)部API級別對比。系統(tǒng)只有在滿足下列情況時(shí)才允許進(jìn)行應(yīng)用程序安裝:如果聲明了android:minSdkVersion屬性,其屬性值必須小于或等于該系統(tǒng)的API級別對應(yīng)的整數(shù)值。如果未聲明,系統(tǒng)會默認(rèn)該應(yīng)用程序運(yùn)行需要的最低API級別是1。如果聲明了android:maxSdkVersion屬性,其屬性值必須等于或大于該系統(tǒng)的API級對應(yīng)的整數(shù)值。如果未聲明,系統(tǒng)會默認(rèn)該應(yīng)用程序沒有最高API級別限制。請通過閱讀文檔<uses%dk>以獲得系統(tǒng)如何處理該屬性的更多信息。應(yīng)用程序清單文件中聲明該屬性后,<uses-sdk>元素看起來應(yīng)類似于下面的例子:<manifest><uses-sdkandroid:minSdkVersion="5"/>???</manifest>這樣做的主要原因是,應(yīng)用程序會通過android:miniSdkVersion聲明的API級別來告知系統(tǒng)一一?該應(yīng)用程序使用的API是指定引入的API級別。假如沒有這種屬性聲明,一個(gè)應(yīng)用程序如果因?yàn)槟承┎恢脑虮话惭b在低級別API系統(tǒng)之上,那么該應(yīng)用程序會在運(yùn)行時(shí)因?yàn)閲L試訪問不存在的API而崩潰。為此,Android系統(tǒng)通過不允許應(yīng)用程序被安裝在不滿足其最低API級別要求的目標(biāo)硬件上來防止此類結(jié)果發(fā)生。例如,android.appwidget類包是在API級別3中開始引入的。如果一個(gè)應(yīng)用程序使用了這個(gè)API,就必須通過指明android:minSdkVersion屬性為3來聲明運(yùn)行的最低要求。于是,該應(yīng)用程序就可以在Android1.5(API級別3級)、Android1.6(API級別4級)等平臺上安裝,但是在Android1.1(API級別2級)和Android1.0平臺(API級別1級)上卻是無法安裝的。欲知關(guān)于如何聲明應(yīng)用程序API級別需求的更多信息,請閱讀文檔中關(guān)于清單文件的<uses-sdk>章節(jié)。開發(fā)者需要考慮的內(nèi)容本節(jié)屬于應(yīng)用程序開發(fā)者需要了解的內(nèi)容。應(yīng)用程序的向前兼容性Android應(yīng)用程序一般向前兼容于Android平臺的新版本。這是因?yàn)閹缀跛械目蚣蹵PI變更都是添加性質(zhì)的,一個(gè)以某種版本的API開發(fā)的應(yīng)用程序是向前兼容與后續(xù)Android系統(tǒng)及高版本API。應(yīng)用程序應(yīng)當(dāng)可以運(yùn)行于高版本的平臺,除非使用了未來因某種原因移除的API。向前兼容性的特性如此重要,是因?yàn)楹芏嗟腁ndroid驅(qū)動(dòng)的設(shè)備能夠使用OTA遠(yuǎn)程下載技術(shù)進(jìn)行系統(tǒng)更新。用戶開始時(shí)能夠很好的安裝和使用你開發(fā)的應(yīng)用程序,后來進(jìn)行了OTA升級到新版本的Android平臺。一旦升級完畢,你的應(yīng)用程序?qū)⑦\(yùn)行在一個(gè)新的版本環(huán)境下,而這個(gè)環(huán)境應(yīng)當(dāng)包含了你的應(yīng)用程序所需的API和系統(tǒng)功能。某些情況下,API背后的變化,例如系統(tǒng)底層的變化,可能會影響到你的應(yīng)用程序運(yùn)行在新的環(huán)境下。為此,作為應(yīng)用程序開發(fā)人員,應(yīng)當(dāng)了解應(yīng)用程序在不同系統(tǒng)環(huán)境下將會有如何的外觀和行為。AndroidSDK包含了多個(gè)平臺版本,開發(fā)人員可以下載下來,用于測試自己的應(yīng)用程序在不同版本下的運(yùn)行情況。每個(gè)版本的平臺都提供了兼容的系統(tǒng)鏡像,你可以將應(yīng)用程序運(yùn)行在對應(yīng)的Android虛擬設(shè)備(模擬器)上進(jìn)行測試。應(yīng)用程序的向后兼容性Android應(yīng)用程序不一定向后兼容于那些比這些應(yīng)用程序開發(fā)環(huán)境低的平臺環(huán)境。Android平臺的每個(gè)新版本包含了新的框架API,例如新的平臺功能,或者替代部分已有的API。應(yīng)用程序在新平臺上可以訪問這些新的API,就像之前提到的,在后續(xù)更新的版本中,這些新功能API也是可以繼續(xù)使用。相反的,因?yàn)樵缙诎姹镜钠脚_不會包含新的API功能,使用了新API的應(yīng)用程序在那些舊平臺上是無法運(yùn)行的。雖然一個(gè)Android平臺設(shè)備不太可能降級到以前的版本,但是需要了解的是:實(shí)際生活中可能會有很多設(shè)備運(yùn)行的是較舊的平臺版本。即使在設(shè)備接收到OTA遠(yuǎn)程下載升級,有些人仍然可能會滯后甚至可能不會收到更新。平臺版本和API級別的選擇當(dāng)你開發(fā)應(yīng)用程序時(shí),你需要選擇一個(gè)平臺用于編譯該應(yīng)用程序。通常,你應(yīng)該在你的應(yīng)用程序可以支持的最低版本的平臺上進(jìn)行編譯。你可以通過尋找最低的可以支持你的應(yīng)用程序編譯的平臺方式來決定你將會支持的最低平臺版本。一旦你確定了支持的最低版本后,你就可以創(chuàng)建對應(yīng)版本的AVD模擬器來全面測試你的應(yīng)用程序。你需要注意的是不要忘記在應(yīng)用程序清單文件中申明android:minSdkVersion屬性,并賦上正確的API級別標(biāo)識。聲明最低API級別如果你開發(fā)的應(yīng)用程序使用了最新平臺上引入的API或平臺特性,你就需要將android:minSdkVersion屬性賦最新平臺的API級別標(biāo)識。這將保證用戶只能在他們的設(shè)備與你的應(yīng)用程序平臺版本兼容情況下安裝。反過來說,這樣能夠保證你的應(yīng)用程序在他們的設(shè)備上表現(xiàn)正常。如果你用了最新的API或平臺特性,但是沒有申明android:minSdkVersion屬性,那么你的應(yīng)用程序在最新平臺上運(yùn)行是沒有穩(wěn)定,但是在早期版本的平臺上是會出錯(cuò)的。在后一種情況,應(yīng)用程序在嘗試訪問舊平臺上不存在的API時(shí)會崩潰。針對高版本的API級別測試編譯完你的應(yīng)用程序,你應(yīng)當(dāng)在支持的最低版本平臺上詳細(xì)測試應(yīng)用程序的表現(xiàn)??梢酝ㄟ^創(chuàng)建對應(yīng)平臺的AVD模擬器進(jìn)行測試。此外,要保證向前兼容性,你應(yīng)當(dāng)在你的應(yīng)用程序可能運(yùn)行的更高平臺版本上進(jìn)行運(yùn)行和測試。AndroidSDK包含了多個(gè)平臺版本供開發(fā)者使用,其中包括了最新的版本,并且提供了升級工具使得開發(fā)者可以獲取其他的版本。要使用升級工具,可以通過Android命令行方式,該工具位于<sdk>/tools路徑下。你可以用敲入android指令運(yùn)行該升級工具,而不用指定任何參數(shù)。你也可以簡單地通過雙擊Windows下的android.bat或OSX/Linux下的android文件來啟動(dòng)升級工具。在ADT工具界面,你可以通過菜單的Window>AndroidSDKandAVDManager來訪問升級工具。要想將你的應(yīng)用程序在不同平臺版本的模擬器上運(yùn)行,需要?jiǎng)?chuàng)建對應(yīng)的AVD設(shè)備。關(guān)于AVD的更多信息,請參見CreatingandManagingVirtualDevices。如果你用物理設(shè)備進(jìn)行測試,確保清楚運(yùn)行的具體平臺版本。通過本文開始部分的映射表格可以知道平臺版本對應(yīng)的API級別標(biāo)識。使用臨時(shí)的API級別某些情況下,有可能會發(fā)布“早期預(yù)覽(EarlyLook)〃版的Android平臺SDK。在此平臺版本上開發(fā)使用的API將不會是最終發(fā)布版,平臺的API級別標(biāo)識數(shù)字就不會指定。你必須在程序清單文件中使用臨時(shí)的API級別進(jìn)行標(biāo)識,以便建立對應(yīng)的平臺應(yīng)用。臨時(shí)API級別不是一個(gè)整數(shù),而是一個(gè)表示未發(fā)布的平臺版本的字符串代號。"早期預(yù)覽〃版本的API級別在發(fā)布說明中會申明,該代號是大小寫敏感的。臨時(shí)API級別標(biāo)識的用途是保護(hù)開發(fā)者和設(shè)備使用者免于無意中發(fā)布或安裝在"早期預(yù)覽〃平臺版本上開發(fā)的應(yīng)用程序,這些應(yīng)用程序可能在最終的發(fā)布系統(tǒng)上運(yùn)行不穩(wěn)定。臨時(shí)API級別標(biāo)識僅僅在使用"早期預(yù)覽〃版本的SDK下有效,并且只能運(yùn)行應(yīng)用程序于模擬器之中。實(shí)際的Android設(shè)備上是無法安裝使用臨時(shí)API級別標(biāo)識的應(yīng)用程序的。在最終版本平臺發(fā)布后,你必須將程序清單文件中用到的臨時(shí)API級別標(biāo)識替換成最終平臺的實(shí)際API級別整數(shù)值。通過API級別進(jìn)行文檔內(nèi)容過濾Android開發(fā)者站點(diǎn)上的參考文檔的每個(gè)頁面的右上方提供了“FilterbyAPILevel〃控件。你可以用這個(gè)控件來僅僅顯示你應(yīng)用程序相關(guān)的那部分API文檔,可以通過應(yīng)用程序清單文件中的android:minSdkVersion屬性值進(jìn)行過濾。要使用過濾功能,可以通過頁面搜索框下面的選擇框來啟用過濾功能。比如設(shè)定“FilterbyAPILevel”控件內(nèi)容與你應(yīng)用程序申明的相同。注意:在選定級別之后引入的心API會以灰色顯示,并且內(nèi)容被隱藏,因?yàn)槟愕膽?yīng)用程序是無法訪問這些新功能。API級別過濾方法不會提供每個(gè)API級別中新添加的功能視圖,僅僅展現(xiàn)對應(yīng)API級別的整個(gè)內(nèi)容,其中去除了后續(xù)新版本中的內(nèi)容。如果你不想過濾API文檔了,只需要關(guān)閉該選擇框的特性。API級別過濾默認(rèn)是關(guān)閉的,因此你可以看到整個(gè)框架API的全貌,而不管具體的API級別。還要注意的是個(gè)別的API元素申明了該API參考文檔在哪一級引入的。這通過在每個(gè)文檔頁面正文部分的右上角的“Since<apilevel〉”進(jìn)行聲明該包和類的引入信息。類成員的API級別在其詳細(xì)描述文件頭部的右邊進(jìn)行描述。AndroidAPILevelsAsyoudevelopyourapplicationonAndroid,it'susefultounderstandtheplatform'sgeneralapproachtoAPIchangemanagement.It'salsoimportanttounderstandtheAPILevelidentifierandtheroleitplaysinensuringyourapplication'scompatibilitywithdevicesonwhichitmaybeinstalled.ThesectionsbelowprovideinformationaboutAPILevelandhowitaffectsyourapplications.Forinformationabouthowtousethe"FilterbyAPILevel"controlavailableintheAPIreferencedocumentation,see attheendofthisdocument.WhatisAPILevel?APILevelisanintegervaluethatuniquelyidentifiestheframeworkAPIrevisionofferedbyaversionoftheAndroidplatform.TheAndroidplatformprovidesaframeworkAPIthatapplicationscanusetointeractwiththeunderlyingAndroidsystem.TheframeworkAPIconsistsof:AcoresetofpackagesandclassesAsetofXMLelementsandattributesfordeclaringamanifestfileAsetofXMLelementsandattributesfordeclaringandaccessingresourcesAsetofIntentsAsetofpermissionsthatapplicationscanrequest,aswellaspermissionenforcementsincludedinthesystemEachsuccessiveversionoftheAndroidplatformcanincludeupdatestotheAndroidapplicationframeworkAPIthatitdelivers.UpdatestotheframeworkAPIaredesignedsothatthenewAPIremainscompatiblewithearlierversionsoftheAPI.Thatis,mostchangesintheAPIareadditiveandintroduceneworreplacementfunctionality.AspartsoftheAPIareupgraded,theolderreplacedpartsaredeprecatedbutarenotremoved,sothatexistingapplicationscanstillusethem.Inaverysmallnumberofcases,partsoftheAPImaybemodifiedorremoved,althoughtypicallysuchchangesareonlyneededtoensureAPIrobustnessandapplicationorsystemsecurity.AllotherAPIpartsfromearlierrevisionsarecarriedforwardwithoutmodification.TheframeworkAPIthatanAndroidplatformdeliversisspecifiedusinganintegeridentifiercalled"APILevel".EachAndroidplatformversionsupportsexactlyoneAPILevel,althoughsupportisimplicitforallearlierAPILevels(downtoAPILevel1).TheinitialreleaseoftheAndroidplatformprovidedAPILevel1andsubsequentreleaseshaveincrementedtheAPILevel.ThefollowingtablespecifiestheAPILevelsupportedbyeachversionoftheAndroidplatform.PlatformVersionAPILevelAndroid3.011Android2.3.310Android2.39Android2.28Android2.17Android2.0.16Android2.05Android1.64Android1.53Android1.12Android1.01UsesofAPILevelinAndroidTheAPILevelidentifierservesakeyroleinensuringthebestpossibleexperienceforusersandapplicationdevelopers:ItletstheAndroidplatformdescribethemaximumframeworkAPIrevisionthatitsupportsItletsapplicationsdescribetheframeworkAPIrevisionthattheyrequireItletsthesystemnegotiatetheinstallationofapplicationsontheuser'sdevice,suchthatversion-incompatibleapplicationsarenotinstalled.EachAndroidplatformversionstoresitsAPILevelidentifierinternally,intheAndroidsystemitself.ApplicationscanuseamanifestelementprovidedbytheframeworkAPI—<usessdk>—todescribetheminimumandmaximumAPILevelsunderwhichtheyareabletorun,aswellasthepreferredAPILevelthattheyaredesignedtosupport.Theelementoffersthreekeyattributes:? android:rninSdkVersion—SpecifiestheminimumAPILevelonwhichtheapplicationisabletorun.Thedefaultvalueis"1".android:targetSdkVersion—SpecifiestheAPILevelonwhichtheapplicationisdesignedtorun.Insomecases,thisallowstheapplicationtousemanifestelementsorbehaviorsdefinedinthetargetAPILevel,ratherthanbeingrestrictedtousingonlythosedefinedfortheminimumAPILevel.android:maxSdkVersion—SpecifiesthemaximumAPILevelonwhichtheapplicationisabletorun.Important:Pleasereadthe〈usvs-sdk〉documentationbeforeusingthisattribute.Forexample,tospecifytheminimumsystemAPILevelthatanapplicationrequiresinordertorun,theapplicationwouldincludeinitsmanifesta〈uses-sdk〉elementwithaandroid:minSdkVersionattribute.Thevalueofandroid:minSdkVersionwouldbetheintegercorrespondingtotheAPILeveloftheearliestversionoftheAndroidplatformunderwhichtheapplicationcanrun.Whentheuserattemptstoinstallanapplication,orwhenrevalidatinganappplicationafterasystemupdate,theAndroidsystemfirstchecksthe〈uses-sdk〉attributesintheapplication'smanifestandcomparesthevaluesagainstitsowninternalAPILevel.Thesystemallowstheinstallationtobeginonlyiftheseconditionsaremet:Ifaandroid:minSdkVersionattributeisdeclared,itsvaluemustbelessthanorequaltothesystem'sAPILevelinteger.Ifnotdeclared,thesystemassumesthattheapplicationrequiresAPILevel1.Ifaandroid:maxSdkVersionattributeisdeclared,itsvaluemustbeequaltoorgreaterthanthesystem'sAPILevelinteger.Ifnotdeclared,thesystemassumesthattheapplicationhasnomaximumAPILevel.Pleasereadthe〈uses-sdk〉documentationformoreinformationabouthowthesystemhandlesthisattribute.Whendeclaredinanapplication'smanifest,a〈uses-sdk〉elementmightlooklikethis:<manifest><uses-sdkandroid:minSdkVersion="5"/>???</manifest>TheprincipalreasonthatanapplicationwoulddeclareanAPILevelinandroid:minSdkVersionistotelltheAndroidsystemthatitisusingAPIsthatwereintroducedintheAPILevelspecified.IftheapplicationweretobesomehowinstalledonaplatformwithalowerAPILevel,thenitwouldcrashatrun-timewhenittriedtoaccessAPIsthatdon'texist.ThesystempreventssuchanoutcomebynotallowingtheapplicationtobeinstalledifthelowestAPILevelitrequiresishigherthanthatoftheplatformversiononthetargetdevice.Forexample,theandroid.appwidgetpackagewasintroducedwithAPILevel3.IfanapplicationusesthatAPI,itmustdeclareaandroid:minSdkVersionattributewithavalueof"3".TheapplicationwillthenbeinstallableonplatformssuchasAndroid1.5(APILevel3)andAndroid1.6(APILevel4),butnotontheAndroid1.1(APILevel2)andAndroid1.0platforms(APILevel1).Formoreinformationabouthowtospecifyanapplication'sAPILevelrequirements,seethe sectionofthemanifestfiledocumentation.DevelopmentConsiderationsThesectionsbelowprovideinformationrelatedtoAPIlevelthatyoushouldconsiderwhendevelopingyourapplication.ApplicationforwardcompatibilityAndroidapplicationsaregenerallyforward-compatiblewithnewversionsoftheAndroidplatform.BecausealmostallchangestotheframeworkAPIareadditive,anAndroidapplicationdevelopedusinganygivenversionoftheAPI(asspecifiedbyitsAPILevel)isforward-compatiblewithlaterversionsoftheAndroidplatformandhigherAPIlevels.TheapplicationshouldbeabletorunonalllaterversionsoftheAndroidplatform,exceptinisolatedcaseswheretheapplicationusesapartoftheAPIthatislaterremovedforsomereason.ForwardcompatibilityisimportantbecausemanyAndroid-powereddevicesreceiveover-the-air(OTA)systemupdates.Theusermayinstallyourapplicationanduseitsuccessfully,thenlaterreceiveanOTAupdatetoanewversionoftheAndroidplatform.Oncetheupdateisinstalled,yourapplicationwillruninanewrun-timeversionoftheenvironment,butonethathastheAPIandsystemcapabilitiesthatyourapplicationdependson.Insomecases,changesbelowtheAPI,suchthoseintheunderlyingsystemitself,mayaffectyourapplicationwhenitisruninthenewenvironment.Forthatreasonit'simportantforyou,astheapplicationdeveloper,tounderstandhowtheapplicationwilllookandbehaveineachsystemenvironment.TohelpyoutestyourapplicationonvariousversionsoftheAndroidplatform,theAndroidSDKincludesmultipleplatformsthatyoucandownload.EachplatformincludesacompatiblesystemimagethatyoucanruninanAVD,totestyourapplication.ApplicationbackwardcompatibilityAndroidapplicationsarenotnecessarilybackwardcompatiblewithversionsoftheAndroidplatformolderthantheversionagainstwhichtheywerecompiled.EachnewversionoftheAndroidplatformcanincludenewframeworkAPIs,suchasthosethatgiveapplicationsaccesstonewplatformcapabilitiesorreplaceexistingAPIparts.ThenewAPIsareaccessibletoapplicationswhenrunningonthenewplatformand,asmentionedabove,alsowhenrunningonlaterversionsoftheplatform,asspecifiedbyAPILevel.Conversely,becauseearlierversionsoftheplatformdonotincludethenewAPIs,applicationsthatusethenewAPIsareunabletorunonthoseplatforms.Althoughit'sunlikelythatanAndroid-powereddevicewouldbedowngradedtoapreviousversionoftheplatform,it'simportanttorealizethattherearelikelytobemanydevicesinthefieldthatrunearlierversionsoftheplatform.EvenamongdevicesthatreceiveOTAupdates,somemightlagandmightnotreceiveanupdateforasignificantamountoftime.SelectingaplatformversionandAPILevelWhenyouaredevelopingyourapplication,youwillneedtochoosetheplatformversionagainstwhichyouwillcompiletheapplication.Ingeneral,youshouldcompileyourapplicationagainstthelowestpossibleversionoftheplatformthatyourapplicationcansupport.Youcandeterminethelowestpossibleplatformversionbycompilingtheapplicationagainstsuccessivelylowerbuildtargets.Afteryoudeterminethelowestversion,youshouldcreateanAVDusingthecorrespondingplatformversion(andAPILevel)andfullytestyourapplication.Makesuretodeclareaandroid:rninSdkVersionattributeintheapplication'smanifestandsetitsvaluetotheAPILeveloftheplatformversion.DeclaringaminimumAPILevelIfyoubuildanapplicationthatusesAPIsorsystemfeaturesintroducedinthelatestplatformversion,youshouldsettheandroid:minSdkVersionattributetotheAPILevelofthelatestplatformversion.ThisensuresthatuserswillonlybeabletoinstallyourapplicationiftheirdevicesarerunningacompatibleversionoftheAndroidplatform.Inturn,thisensuresthatyourapplicationcanfunctionproperlyontheirdevices.IfyourapplicationusesAPIsintroducedinthelatestplatformversionbutdoesnotdeclareaandroid:minSdkVersionattribute,thenitwillrunproperlyondevicesrunningthelatestversionoftheplatform,butnotondevicesrunningearlierversionsoftheplatform.Inthelattercase,theapplicationwillcrashatruntimewhenittriestouseAPIsthatdon'texistontheearlierversions.TestingagainsthigherAPILevelsAftercompilingyourapplication,youshouldmakesuretotestitontheplatformspecifiedintheapplication'sandroid:minSdkVersionattribute.Todoso,createanAVDthatusestheplatformversionrequiredbyyourapplication.Additionally,toensureforward-compatibility,youshouldrunandtesttheapplicationonallplatformsthatuseahigherAPILevelthanthatusedbyyourapplication.TheAndroidSDKincludesmultipleplatformversionsthatyoucanuse,includingthelatestversion,andprovidesanupdatertoolthatyoucanusetodownloadotherplatformversionsasnecessary.Toaccesstheupdater,usetheandroidcommand-linetool,locatedinthe<sdk>/toolsdirectory.YoucanlaunchtheUpdaterbyusingtheandroidcommandwithoutspecifyinganyoptions.Youcanalsosimplydouble-clicktheandroid.bat(Windows)orandroid(OSX/Linux)file.InADT,youcanalsoaccesstheupdaterbyselectingWindow>AndroidSDKandAVDManager.Torunyourapplicationagainstdifferentplatformversionsintheemulator,createanAVDforeachplatformversionthatyouwanttotest.FormoreinformationaboutAVDs,seeCreatingandManagingVirtualDevices.Ifyouareusingaphysicaldevicefortesting,ensurethatyouknowtheAPILeveloftheAndroidplatformitruns.SeethetableatthetopofthisdocumentforalistofplatformversionsandtheirAPILevels.UsingaProvisionalAPILevelInsomecases,an"EarlyLook"AndroidSDKplatformmaybeavailable.ToletyoubegindevelopingontheplatformalthoughtheAPIsmaynotbefinal,theplatform'sAPILevelintegerwillnotbespecified.Youmustinsteadusetheplatform'sprovisionalAPILevelyourapplicationmanifest,inordertobuildapplicationsagainsttheplatform.AprovisionalAPILevelisnotaninteger,butastringmatchingthecodenameoftheunreleasedplatformversion.TheprovisionalAPILevelwillbespecifiedinthereleasenotesfortheEarlyLookSDKreleasenotesandiscase-sensitive.TheuseofaprovisionalAPILevelisdesignedtoprotectdevelopersanddeviceusersfrominadvertentlypublishingorinstallingapplicationsbasedontheEarlyLookframeworkAPI,whichmaynotrunproperl

溫馨提示

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

評論

0/150

提交評論