Retrieving Android API version programmatically

前端 未结 11 2138
长情又很酷
长情又很酷 2020-11-22 04:54

Is there any way to get the API version that the phone is currently running?

11条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 05:23

    I improved code i used

    public static float getAPIVerison() {
    
        float f=1f;
        try {
            StringBuilder strBuild = new StringBuilder();
            strBuild.append(android.os.Build.VERSION.RELEASE.substring(0, 2));
            f= Float.valueOf(strBuild.toString());
        } catch (NumberFormatException e) {
            Log.e("myApp", "error retriving api version" + e.getMessage());
        }
    
        return f;
    }
    

提交回复
热议问题