Does Android have any way to detect the cyanogenmod and its version?

I am working on an Android media player that needs an equalizer. However, the equalizer is only available on Gingerbread and above, but cyanogenmod 6 has a modified audio fragment to act as an equalizer, so I want to determine the OS version.

+2
source share
3 answers

You can read the os.version property and map to it:

 String version = System.getProperty("os.version"); if (version.contains("cyanogenmod")) { isCyanogenMode = true; } 

On my os.version device os.version is 2.6.37.6-cyanogenmod-01509-g8913be8 .

+4
source

To date, the cyanogenmod kernel does not contain the cyanogenmod keyword in System.getProperty("os.version"); This is something like 3.0.64-CM-g9d16c8a . Therefore, I wrote this function.

 private boolean isCyanogenMod(PackageManager pm) { boolean isCyanogenMod = false; String version = System.getProperty("os.version"); BufferedReader reader = null; try { if (version.contains("cyanogenmod") || pm.hasSystemFeature("com.cyanogenmod.android")) { isCyanogenMod = true; } else { // This does not require root reader = new BufferedReader(new FileReader("/proc/version"), 256); version = reader.readLine(); if (version.contains("cyanogenmod")) { isCyanogenMod = true; } } } catch (Exception e) { e.printStackTrace(); } finally { if(reader != null) { try { reader.close(); } catch (IOException e) { } } } return isCyanogenMod; } 
+4
source

Well, this is an old question, but I recently came up with the best solution that I think.

 public static boolean isCyanogenMod() { try { return Class.forName("cyanogenmod.os.Build") != null; } catch (Exception ignored) { } return false; } 
+2
source

Source: https://habr.com/ru/post/1346031/


All Articles