Backward Compatibility for Applications 翻译

Backward Compatibility for Applications 翻译

ID:38412478

大小:22.04 KB

页数:7页

时间:2019-06-12

Backward Compatibility for Applications 翻译_第1页
Backward Compatibility for Applications 翻译_第2页
Backward Compatibility for Applications 翻译_第3页
Backward Compatibility for Applications 翻译_第4页
Backward Compatibility for Applications 翻译_第5页
资源描述:

《Backward Compatibility for Applications 翻译》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、BackwardCompatibilityforApplications应用的向后兼容AvarietyofAndroid-powereddevicesarenowavailabletoconsumersfromcarriersingeographiesaroundtheworld.Acrossthosedevices,arangeofAndroidplatformversionsareinuse,somerunningthelatestversionoftheplatform,othersrunningolderversions.Asadeveloper,youneedtoconsid

2、ertheapproachtobackwardcompatibilitythatyouwilltakeinyourapplication—doyouwanttoallowyourapplicationtorunonalldevices,orjustthoserunningthelatestsoftware?InsomecasesitwillbeusefultoemploythenewerAPIsondevicesthatsupportthem,whilecontinuingtosupportolderdevices.一种android-powered设备现在可以被全世界各地的消费者使用

3、。通过这个设备,一系列的android平台版本正在被使用,一些运行着最新的平台版本,另一些运行着比较老的版本。作为一个开发者,你需要为你的应用考虑一个向后兼容的途径,你想让你的应用能跑在所有的设备上,还是只能跑那些最新的软件?在一些情形下,在支持他们的设备上使用比较新的APIs对于继续支持较老的设备是相当有用的。SettingtheminSdkVersionIftheuseofanewAPIisintegraltotheapplication—perhapsyouneedtorecordvideousinganAPIintroducedinAndroid1.5(APILevel3)—y

4、oushouldaddatotheapplication'smanifest,toensureyourappwon'tbeinstalledonolderdevices.Forexample,ifyourapplicationdependsonanAPIintroducedinAPILevel3,youwouldspecify"3"asthevalueoftheminimumSDKversion:   ...    ... Ho

5、wever,ifyouwanttoaddausefulbutnon-essentialfeature,suchaspoppingupanon-screenkeyboardevenwhenahardwarekeyboardisavailable,youcanwriteyourprograminawaythatallowsittousethenewerfeatureswithoutfailingonolderdevices.UsingreflectionSupposethere'sasimplenewcallyouwanttouse,likeandroid.os.Debug.dumpHpr

6、ofData(Stringfilename).TheDebugclasshasexistedsinceAndroid1.0,butthemethodisnewinAnroid1.5(APILevel3).Ifyoutrytocallitdirectly,yourappwillfailtorunondevicesrunningAndroid1.1orearlier.Thesimplestwaytocallthemethodisthroughreflection.Thisrequiresdoingaone-timelookupandcachingtheresultinaMethodobje

7、ct.UsingthemethodisamatterofcallingMethod.invokeandun-boxingtheresult.Considerthefollowing:publicclassReflect{  privatestaticMethodmDebug_dumpHprofData;  static{    initCompatibility();  };  privatestaticvoidinitCompatibilit

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。