admin管理员组

文章数量:1629912

android鸿蒙系统校验

因需求需要从用户设备获取手机系统,鸿蒙系统的获取方式如下,目前只能通过反映获取。

/**
* 校验是否是鸿蒙系统
*
* @return true-鸿蒙系统
*/
public static boolean isHarmonyOS() {
    try {
        Class clz = Class.forName("com.huawei.system.BuildEx");
        Method method = clz.getMethod("getOsBrand");
        return "harmony".equals(method.invoke(clz));
    } catch (ClassNotFoundException e) {
        Log.e(TAG, "occured ClassNotFoundException");
    } catch (Exception e) {
        Log.e(TAG, "occur other problem");
    }
    return false;
}

本文标签: 鸿蒙运行环境方法系统android