プログラムでOSはHarmony(HarmonyOS)かAndroidか判断する方法
ファーウェイは2021年7月23日にHUAWEI MatePad 11をリリースしました。このタブレットはHarmonyOSを搭載しています。AndroidのアプリもHarmonyOSのアプリも正常動作します。
アプリの中でOSがHarmonyOSかAndroidか判断する場面があるかもしれないので、その方法を公開します。
public boolean isHarmonyOS() {
try {
Class classType = Class.forName("com.huawei.system.BuildEx");
Method method = classType.getMethod("getOsBrand");
ClassLoader classLoader = classType.getClassLoader();
if (classLoader != null && classLoader.getParent() == null) {
return "harmony".equals(method.invoke(classType));
}
} catch (ClassNotFoundException e) {
} catch (NoSuchMethodException e) {
} catch (Exception e) {
}
return false;
}
Author And Source
この問題について(プログラムでOSはHarmony(HarmonyOS)かAndroidか判断する方法), 我々は、より多くの情報をここで見つけました https://qiita.com/Rei_2020/items/85d4eac0a64091119573著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .