欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
Android應用在不同版本間兼容性處理

       在A(yíng)ndroid系統中向下兼容性比較差,但是一個(gè)應用APP經(jīng)過(guò)處理還是可以在各個(gè)版本間運行的。向下兼容性不好,不同版本的系統其API版本也不同,自然有些接口也不同,新的平臺不能使用舊的API,舊的平臺也使用不了新的API。

        為了應用APP有更好的兼容性,咱們可以利用高版本的SDK開(kāi)發(fā)應用,并在程序運行時(shí)(Runtime)對應用所運行的平臺判斷,舊平臺使用舊的API,而新平臺可使用新的API,這樣可以較好的提高軟件兼容性。


        那么,如何在軟件運行時(shí)做出這樣的判斷呢?答案下邊揭曉:


  在A(yíng)ndroid SDK開(kāi)發(fā)文檔中有段話(huà)這樣的話(huà):

Check System Version at Runtime(在軟件運行時(shí)檢查判斷系統版本)


Android provides a unique code for each platform version in theBuild constants class. Use these codes within your app to build conditions that ensure the code thatdepends on higher API levels is executed only when those APIs are available on the system.

private void setUpActionBar() {    // Make sure we're running on Honeycomb or higher to use ActionBar APIs    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {         ActionBar actionBar = getActionBar();         actionBar.setDisplayHomeAsUpEnabled(true);    }}

Note: When parsing XML resources, Android ignores XML attributes that aren’t supported by the current device. So you can safely use XML attributes thatare only supported by newer versions without worrying about older versions breaking when theyencounter that code. For example, if you set thetargetSdkVersion="11", your app includes the ActionBar by defaulton Android 3.0 and higher. To then add menu items to the action bar, you need to setandroid:showAsAction="ifRoom" in your menu resource XML. It's safe to do this in a cross-version XML file, because the older versions of Android simply ignore theshowAsAction attribute (that is, you do not need a separate version inres/menu-v11/).


           從上面可以知道Android為我們提供了一個(gè)常量類(lèi)Build,其中最主要是Build中的兩個(gè)內部類(lèi)VERSION和VERSION_CODES,

VERSION表示當前系統版本的信息,其中就包括SDK的版本信息,用于成員SDK_INT表示;

對于VERSION_CODES在SDK開(kāi)發(fā)文檔中時(shí)這樣描述的,Enumeration of the currently known SDK version codes. These are the values that can be found inSDK. Version numbers increment monotonically with each official platform release.

其成員就是一些從最早版本開(kāi)始到當前運行的系統的一些版本號常量。

  在我們自己開(kāi)發(fā)應用過(guò)程中,常常使用如下的代碼形式判斷運行新API還是舊的API:

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)     {            // 包含新API的代碼塊    }    else    {            // 包含舊的API的代碼塊    }
     OK,大家都知道原理了吧! 需要實(shí)例的百度蠻多的,這里就不提供了。


本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
關(guān)于Eclipse創(chuàng )建Android項目時(shí),會(huì )多出一個(gè)appcompat
Android中build target,minSdkVersion,targetSdkVersio...
什么是Android API 級別?
uses-sdk配置
Android 14的第一個(gè)開(kāi)發(fā)者預覽版
Android Gradle插件(plugin)版本(version)與Gradle、SDK Build Tools版本關(guān)系
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久