Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tell if device is running a MIUI software

I need to know if my app is running on a MIUI device like XIAOMI at runtime due to issues like pre android 6.0 permissions etc.

Is there a way to to do it?

like image 237
roiberg Avatar asked Dec 13 '22 21:12

roiberg


1 Answers

I've found a gist on github that aims to do just that, by trying to fetch the "ro.miui.ui.version.name" system property.

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;
}

Origin on github

like image 189
Gil Fidel Avatar answered Dec 24 '22 13:12

Gil Fidel