通过反射判断当前设备是Android还是Harmony
3264 浏览 29 点赞 25 收藏
private static final String HARMONY_OS = “harmony”;
/**
- check the system is harmony os
- @return true if it is harmony os
*/
public static boolean isHarmonyOS() {
try {
Class clz = Class.forName(“com.huawei.system.BuildEx”);
Method method = clz.getMethod(“getOsBrand”);
return HARMONY_OS.equals(method.invoke(clz));
} catch (ClassNotFoundException e) {
Log.e(TAG, “occured ClassNotFoundException”);
} catch (NoSuchMethodException e) {
Log.e(TAG, “occured NoSuchMethodException”);
} catch (Exception e) {
Log.e(TAG, “occur other problem”);
}
return false;
}
©本站发布的所有内容,包括但不限于文字、图片、音频、视频、图表、标志、标识、广告、商标、商号、域名、软件、程序等,除特别标明外,均来源于网络或用户投稿,版权归原作者或原出处所有。我们致力于保护原作者版权,若涉及版权问题,请及时联系我们进行处理。
分类
其它
标签
鸿蒙
操作系统
HarmonyOS
相关推荐
HarmonyOS分布式能力实战:跨设备迁移与协同
栀枝夏
1125
0鸿蒙应用设备指纹与风控组件开发
User_芊芊君子
2207
0基于 @ohos.deviceInfo 的多设备适配策略与运行时判断
王争
1315
0MOR系列通过3C认证
程序巫师
1249
0噗噗嗤嗤
我还没有写个人简介......
195
帖子
0
提问
1361
粉丝
最新发布
AWS:智能体不该是“秘密特工”,所以为它们建了个注册中心
2026-04-10 10:39:26 发布华为“鸿蒙有礼特别版”今日上线,活动期间每天可领 10 元优惠券
2025-09-30 19:01:02 发布热门推荐
京公网安备:11010502051901号