Skip to content

MIUI 9之后,以前的方法无效,统一成原生的方法了 #7

@ditclear

Description

@ditclear

见文档:https://dev.mi.com/console/doc/detail?pId=1159
代码修改如下

//    /**
////     * 判断是否为MIUI6以上
////     */
////    public static boolean isMIUI6Later() {
////        try {
////            Class<?> clz = Class.forName("android.os.SystemProperties");
////            Method mtd = clz.getMethod("get", String.class);
////            String val = (String) mtd.invoke(null, "ro.miui.ui.version.name");
////            val = val.replaceAll("[vV]", "");
////            int version = Integer.parseInt(val);
////            return version >= 6;
////        } catch (Exception e) {
////            return false;
////        }
////    }
  
   /**
     * 判断是否为MIUI6以上9以下
     */
    public static boolean isMIUI6LaterAnd9Before() {
        try {
            Class<?> clz = Class.forName("android.os.SystemProperties");
            Method mtd = clz.getMethod("get", String.class);
            String val = (String) mtd.invoke(null, "ro.miui.ui.version.name");
            val = val.replaceAll("[vV]", "");
            int version = Integer.parseInt(val);
            return version >= 6 && version < 9;
        } catch (Exception e) {
            return false;
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions