Does every Android device contains all previous SDK versions? -
i'm wondering, if latest android sdk installed on device contains code of previous versions well?
so if target api level 10 in app , install on device lollipop, take , use gingerbread sdk 3 years ago?
or there 1 codebase versions lot of checks , switches run kind of compatibility mode picking correct code , enabling methods of version of sdk target?
i read article android:targetsdkversion specified in manifest still know how works internally.
ok, surfed bit around on source code (which can find here: https://github.com/android/platform_frameworks_base). i'm not engineer of android framework, curious question , here found.
it not contain different versions of source code. can imagine result in nightmare if more , more versions become available. foremost, have different (buggy) versions of same method without fixing them keep them same.
in source code, can find places these: (see https://github.com/android/platform_frameworks_base/blob/59701b9ba5c453e327bc0e6873a9f6ff87a10391/core/java/com/android/internal/view/actionbarpolicy.java#l55)
public boolean hasembeddedtabs() { final int targetsdk = mcontext.getapplicationinfo().targetsdkversion; if (targetsdk >= build.version_codes.jelly_bean) { return mcontext.getresources().getboolean(r.bool.action_bar_embed_tabs); } // ... return mcontext.getresources().getboolean(r.bool.action_bar_embed_tabs_pre_jb); }
so android developers version check in code necessary. these checks not necessary think (i guess). what's reason changing method?
- method buggy: need fix bug. tests make sure general behavior of method keeps same
- method deprecated: guys can not remove method, can mark deprecated , hope best. compilers rest.
- method behavior has change: well, guess can not easily. can work around version codes (which pretty ugly , becomes maintenance nightmare), or introduce new api. that's reason why you'll find lot of apis doing same
Comments
Post a Comment