Code example for Field

Methods: getInt

0
    public static int getAPILevel() { 
        int apiLevel;
        try { 
            // This field has been added in Android 1.6 
            final Field SDK_INT = Build.VERSION.class.getField("SDK_INT");
            apiLevel = SDK_INT.getInt(null);
        } catch (SecurityException e) {
            apiLevel = Integer.parseInt(Build.VERSION.SDK);
        } catch (NoSuchFieldException e) {
            apiLevel = Integer.parseInt(Build.VERSION.SDK);
        } catch (IllegalArgumentException e) {
            apiLevel = Integer.parseInt(Build.VERSION.SDK);
        } catch (IllegalAccessException e) {
            apiLevel = Integer.parseInt(Build.VERSION.SDK);
        } 
 
        return apiLevel;
    } 
 
    /** 
     * Retrieve the DropBoxManager service name using reflection API.