3

I wish to receive the custom ROM/Android OS name from device e.g. Let’s say if device is:

Oppo -> ColorOS

OnePlus -> OxygenOS

Huawei -> HarmonyOS

I've used the following methods also, but no success.

Build.DISPLAY -> ONEPLUS A6003_22_201116

Build.VERSION.BASE_OS -> "" // returns empty string

System.getProperty("os.name") -> Linux

System.getProperty("os.version") -> 4.9.179-perf+

System.getProperty("ro.modversion") -> null // returns null

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
Waqar UlHaq
  • 6,144
  • 2
  • 34
  • 42

1 Answers1

-1

You can use the following method to check and get HarmonyOS:

public static boolean isHarmony(Context context) {
    try {
        int id = Resources.getSystem().getIdentifier("config_os_brand", "string", "android");
        return context.getString(id).equals("harmony");
    } catch (Exception e) {
        return false;
    }
}
Zinna
  • 1,947
  • 2
  • 5
  • 20