Skip to content

Instantly share code, notes, and snippets.

@hvu0712
Forked from Muyangmin/DeviceDetectUtil.java
Created September 14, 2023 09:57
Show Gist options
  • Save hvu0712/dfd5440a2994522f406f35880bfae294 to your computer and use it in GitHub Desktop.
Save hvu0712/dfd5440a2994522f406f35880bfae294 to your computer and use it in GitHub Desktop.
detect android device info, MIUI version, etc.
public static boolean isMiUi() {
return !TextUtils.isEmpty(getSystemProperty("ro.miui.ui.version.name"));
}
public static String getSystemProperty(String propName) {
String line;
BufferedReader input = null;
try {
java.lang.Process p = Runtime.getRuntime().exec("getprop " + propName);
input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
line = input.readLine();
input.close();
} catch (IOException ex) {
return null;
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return line;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment