文献翻译.docx

上传人:b****4 文档编号:12325011 上传时间:2023-04-18 格式:DOCX 页数:15 大小:25.10KB
下载 相关 举报
文献翻译.docx_第1页
第1页 / 共15页
文献翻译.docx_第2页
第2页 / 共15页
文献翻译.docx_第3页
第3页 / 共15页
文献翻译.docx_第4页
第4页 / 共15页
文献翻译.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

文献翻译.docx

《文献翻译.docx》由会员分享,可在线阅读,更多相关《文献翻译.docx(15页珍藏版)》请在冰豆网上搜索。

文献翻译.docx

文献翻译

AndroidAPILevels

AsyoudevelopyourapplicationonAndroid,it'susefultounderstandtheplatform'sgeneralapproachtoAPIchangemanagement.It'salsoimportanttounderstandtheAPILevelidentifierandtheroleitplaysinensuringyourapplication'scompatibilitywithdevicesonwhichitmaybeinstalled.

ThesectionsbelowprovideinformationaboutAPILevelandhowitaffectsyourapplications.

Forinformationabouthowtousethe"FilterbyAPILevel"controlavailableintheAPIreferencedocumentation,see Filteringthedocumentation attheendofthisdocument.

WhatisAPILevel?

APILevelisanintegervaluethatuniquelyidentifiestheframeworkAPIrevisionofferedbyaversionoftheAndroidplatform.

TheAndroidplatformprovidesaframeworkAPIthatapplicationscanusetointeractwiththeunderlyingAndroidsystem.TheframeworkAPIconsistsof:

∙Acoresetofpackagesandclasses

∙AsetofXMLelementsandattributesfordeclaringamanifestfile

∙AsetofXMLelementsandattributesfordeclaringandaccessingresources

∙AsetofIntents

∙Asetofpermissionsthatapplicationscanrequest,aswellaspermissionenforcementsincludedinthesystem

EachsuccessiveversionoftheAndroidplatformcanincludeupdatestotheAndroidapplicationframeworkAPIthatitdelivers.

UpdatestotheframeworkAPIaredesignedsothatthenewAPIremainscompatiblewithearlierversionsoftheAPI.Thatis,mostchangesintheAPIareadditiveandintroduceneworreplacementfunctionality.AspartsoftheAPIareupgraded,theolderreplacedpartsaredeprecatedbutarenotremoved,sothatexistingapplicationscanstillusethem.Inaverysmallnumberofcases,partsoftheAPImaybemodifiedorremoved,althoughtypicallysuchchangesareonlyneededtoensureAPIrobustnessandapplicationorsystemsecurity.AllotherAPIpartsfromearlierrevisionsarecarriedforwardwithoutmodification.

TheframeworkAPIthatanAndroidplatformdeliversisspecifiedusinganintegeridentifiercalled"APILevel".EachAndroidplatformversionsupportsexactlyoneAPILevel,althoughsupportisimplicitforallearlierAPILevels(downtoAPILevel1).TheinitialreleaseoftheAndroidplatformprovidedAPILevel1andsubsequentreleaseshaveincrementedtheAPILevel.

ThefollowingtablespecifiestheAPILevelsupportedbyeachversionoftheAndroidplatform.

PlatformVersion

APILevel

Android3.0

11

Android2.3.3

10

Android2.3

9

Android2.2

8

Android2.1

7

Android2.0.1

6

Android2.0

5

Android1.6

4

Android1.5

3

Android1.1

2

Android1.0

1

UsesofAPILevelinAndroid

TheAPILevelidentifierservesakeyroleinensuringthebestpossibleexperienceforusersandapplicationdevelopers:

∙ItletstheAndroidplatformdescribethemaximumframeworkAPIrevisionthatitsupports

∙ItletsapplicationsdescribetheframeworkAPIrevisionthattheyrequire

∙Itletsthesystemnegotiatetheinstallationofapplicationsontheuser'sdevice,suchthatversion-incompatibleapplicationsarenotinstalled.

EachAndroidplatformversionstoresitsAPILevelidentifierinternally,intheAndroidsystemitself.

ApplicationscanuseamanifestelementprovidedbytheframeworkAPI—  —todescribetheminimumandmaximumAPILevelsunderwhichtheyareabletorun,aswellasthepreferredAPILevelthattheyaredesignedtosupport.Theelementoffersthreekeyattributes:

∙android:

minSdkVersion —SpecifiestheminimumAPILevelonwhichtheapplicationisabletorun.Thedefaultvalueis"1".

∙android:

targetSdkVersion —SpecifiestheAPILevelonwhichtheapplicationisdesignedtorun.Insomecases,thisallowstheapplicationtousemanifestelementsorbehaviorsdefinedinthetargetAPILevel,ratherthanbeingrestrictedtousingonlythosedefinedfortheminimumAPILevel.

∙android:

maxSdkVersion —SpecifiesthemaximumAPILevelonwhichtheapplicationisabletorun. Important:

 Pleasereadthe  documentationbeforeusingthisattribute.

Forexample,tospecifytheminimumsystemAPILevelthatanapplicationrequiresinordertorun,theapplicationwouldincludeinitsmanifesta  elementwitha android:

minSdkVersion attribute.Thevalueof android:

minSdkVersion wouldbetheintegercorrespondingtotheAPILeveloftheearliestversionoftheAndroidplatformunderwhichtheapplicationcanrun.

Whentheuserattemptstoinstallanapplication,orwhenrevalidatinganappplicationafterasystemupdate,theAndroidsystemfirstchecksthe  attributesintheapplication'smanifestandcomparesthevaluesagainstitsowninternalAPILevel.Thesystemallowstheinstallationtobeginonlyiftheseconditionsaremet:

∙Ifa android:

minSdkVersion attributeisdeclared,itsvaluemustbelessthanorequaltothesystem'sAPILevelinteger.Ifnotdeclared,thesystemassumesthattheapplicationrequiresAPILevel1.

∙Ifa android:

maxSdkVersion attributeisdeclared,itsvaluemustbeequaltoorgreaterthanthesystem'sAPILevelinteger.Ifnotdeclared,thesystemassumesthattheapplicationhasnomaximumAPILevel.Pleasereadthe  documentationformoreinformationabouthowthesystemhandlesthisattribute.

Whendeclaredinanapplication'smanifest,a  elementmightlooklikethis:

 

minSdkVersion="5"/>

 ...

TheprincipalreasonthatanapplicationwoulddeclareanAPILevelin android:

minSdkVersion istotelltheAndroidsystemthatitisusingAPIsthatwere introduced intheAPILevelspecified.IftheapplicationweretobesomehowinstalledonaplatformwithalowerAPILevel,thenitwouldcrashatrun-timewhenittriedtoaccessAPIsthatdon'texist.ThesystempreventssuchanoutcomebynotallowingtheapplicationtobeinstalledifthelowestAPILevelitrequiresishigherthanthatoftheplatformversiononthetargetdevice.

Forexample,the android.appwidget packagewasintroducedwithAPILevel3.IfanapplicationusesthatAPI,itmustdeclarea android:

minSdkVersion attributewithavalueof"3".TheapplicationwillthenbeinstallableonplatformssuchasAndroid1.5(APILevel3)andAndroid1.6(APILevel4),butnotontheAndroid1.1(APILevel2)andAndroid1.0platforms(APILevel1).

Formoreinformationabouthowtospecifyanapplication'sAPILevelrequirements,seethe  sectionofthemanifestfiledocumentation.

DevelopmentConsiderations

ThesectionsbelowprovideinformationrelatedtoAPIlevelthatyoushouldconsiderwhendevelopingyourapplication.

Applicationforwardcompatibility

Androidapplicationsaregenerallyforward-compatiblewithnewversionsoftheAndroidplatform.

BecausealmostallchangestotheframeworkAPIareadditive,anAndroidapplicationdevelopedusinganygivenversionoftheAPI(asspecifiedbyitsAPILevel)isforward-compatiblewithlaterversionsoftheAndroidplatformandhigherAPIlevels.TheapplicationshouldbeabletorunonalllaterversionsoftheAndroidplatform,exceptinisolatedcaseswheretheapplicationusesapartoftheAPIthatislaterremovedforsomereason.

ForwardcompatibilityisimportantbecausemanyAndroid-powereddevicesreceiveover-the-air(OTA)systemupdates.Theusermayinstallyourapplicationanduseitsuccessfully,thenlaterreceiveanOTAupdatetoanewversionoftheAndroidplatform.Oncetheupdateisinstalled,yourapplicationwillruninanewrun-timeversionoftheenvironment,butonethathastheAPIandsystemcapabilitiesthatyourapplicationdependson.

Insomecases,changes below theAPI,suchthoseintheunderlyingsystemitself,mayaffectyourapplicationwhenitisruninthenewenvironment.Forthatreasonit'simportantforyou,astheapplicationdeveloper,tounderstandhowtheapplicationwilllookandbehaveineachsystemenvironment.TohelpyoutestyourapplicationonvariousversionsoftheAndroidplatform,theAndroidSDKincludesmultipleplatformsthatyoucandownload.EachplatformincludesacompatiblesystemimagethatyoucanruninanAVD,totestyourapplication.

Applicationbackwardcompatibility

AndroidapplicationsarenotnecessarilybackwardcompatiblewithversionsoftheAndroidplatformolderthantheversionagainstwhichtheywerecompiled.

EachnewversionoftheAndroidplatformcanincludenewframeworkAPIs,suchasthosethatgiveapplicationsaccesstonewplatformcapabilitiesorreplaceexistingAPIparts.ThenewAPIsareaccessibletoapplicationswhenrunningonthenewplatformand,asmentionedabove,alsowhenrunningonlaterversionsoftheplatform,asspecifiedbyAPILevel.Conversely,becauseearlierversionsoftheplatformdonotincludethenewAPIs,applicationsthatusethenewAPIsareunabletorunonthoseplatforms.

Althoughit'sunlikelythatanAndroid-powereddevicewouldbedowngradedtoapreviousversionoftheplatform,it'simportanttorealizethattherearelikelytobemanydevicesinthefieldthatrunearlierversionsoftheplatform.EvenamongdevicesthatreceiveOTAupdates,somemightlagandmightnotreceiveanupdateforasignificantamountoftime.

SelectingaplatformversionandAPILevel

Whenyouaredevelopingyourapplication,youwillneedtochoosetheplatformversionagainstwhichyouwillcompiletheapplication.Ingeneral,youshouldcompileyourapplicationagainstthelowestpossibleversionoftheplatformthatyourapplicationcansupport.

Youcandeterminethelowestpossibleplatformversionbycompilingtheapplicationagainstsuccessivelylowerbuildtargets.Afteryoudeterminethelowestversion,youshouldcreateanAVDusingthecorrespondingplatformversion(andAPILevel)andfullytestyourapplication.Makesuretodeclarea a

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 幼儿教育 > 育儿知识

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1