开发者

Any way programatically to check the version of android platform

开发者 https://www.devze.com 2023-03-13 07:42 出处:网络
Is there any programatically way for my android application to know which version of and开发者_如何学JAVAroid platform (1.6 or 2.0 or 2.3) that it is currently running on?

Is there any programatically way for my android application to know which version of and开发者_如何学JAVAroid platform (1.6 or 2.0 or 2.3) that it is currently running on?

Thank you.


Here's an example to test for Froyo, pretty self explanatory for other versions

For below API level 4:

           int b = Integer.parseInt(Build.VERSION.SDK);
            Log.i(TAG, "SDK: "+b);

For above API lvl 4:

            int b = Build.VERSION.SDK_INT;
            Log.i(TAG, "SDK: "+b);

Version:

           if(b == Build.VERSION_CODES.FROYO){
                Log.i(TAG, "Found Froyo");
            }


The Build Class is easy to use : Build

if(Integer.decode(Build.VERSION.SDK) >=8) {
// shiny APIS 
 } else  {
    // old APIS
 }

check the excellent presentation by Reto Meier and the Parallel Activity pattern : here


Maybe this helps http://developer.android.com/reference/android/os/Build.VERSION.html


Use SDK_INT to compare with the various flavours

0

精彩评论

暂无评论...
验证码 换一张
取 消