当前位置:   article > 正文

判断手机是否为鸿蒙系统_js 判断鸿蒙系统

js 判断鸿蒙系统

现在华为更新了鸿蒙,今天搜了一波是否为鸿蒙,记录一下。

String manufacturer = getDeviceManufacturer();
//是否为华为和手机系统是否大于Android10
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && manufacturer.equals("HUAWEI")){
    boolean harmonyOs = isHarmonyOs();
    if(harmonyOs){
        ConfigTest.isHarmonyOs = "Harmony";
    }
}else{
    ConfigTest.isHarmonyOs = "Android";
}

//返回手机厂商
public String getDeviceManufacturer() {
    Build b = new Build();
    String manufacturer = b.MANUFACTURER;
    return manufacturer;
}

/**
 * 是否为鸿蒙系统
 *
 * @return true为鸿蒙系统
 */
public static boolean isHarmonyOs() {
    try {
        Class<?> buildExClass = Class.forName("com.huawei.system.BuildEx");
        Object osBrand = buildExClass.getMethod("getOsBrand").invoke(buildExClass);
        return HARMONY_OS.equalsIgnoreCase(osBrand.toString());
    } catch (Throwable x) {
        return false;
    }
}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/249659
推荐阅读
相关标签
  

闽ICP备14008679号