Skip to content

Instantly share code, notes, and snippets.

@Muyangmin
Created July 6, 2016 09:09
Show Gist options
  • Save Muyangmin/e8ec1002c930d8df3df46b306d03315d to your computer and use it in GitHub Desktop.
Save Muyangmin/e8ec1002c930d8df3df46b306d03315d 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;
}
@OlivierFreyssinet-old
Copy link

Thank you!

@Arohap
Copy link

Arohap commented Jan 7, 2022

Thank you <3

@AdverseGecko3
Copy link

Thanks man!!!

@starry-shivam
Copy link

I've created a Kotlin version of this method with some additions like ability to either exclude or include Hyper-OS in the check, based on some research done with one of the user of my app, If anyone finds it useful, here's the link: https://gist.github.com/starry-shivam/901267c26eb030eb3faf1ccd4d2bdd32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment