废话不多说了,直接给大家贴代码了:
具体代码如下所示:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
public class MIUIUtils {
// 检测MIUI
private static final String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code" ;
private static final String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name" ;
private static final String KEY_MIUI_INTERNAL_STORAGE = "ro.miui.internal.storage" ;
public static boolean isMIUI() {<span style= "white-space:pre" >
</span> //获取缓存状态
if (SPUtils.getInstance().getCacheDataSP().contains( "isMIUI" ))
{
return SPUtils.getInstance().getCacheDataSP().getBoolean( "isMIUI" , false );
}
Properties prop= new Properties();
boolean isMIUI;
try {
prop.load( new FileInputStream( new File(Environment.getRootDirectory(), "build.prop" )));
} catch (IOException e)
{
e.printStackTrace();
return false ;
}
isMIUI= prop.getProperty(KEY_MIUI_VERSION_CODE, null ) != null
|| prop.getProperty(KEY_MIUI_VERSION_NAME, null ) != null
|| prop.getProperty(KEY_MIUI_INTERNAL_STORAGE, null ) != null ;
SPUtils.getInstance().putCacheData( "isMIUI" ,isMIUI); //保存是否MIUI
return isMIUI;
}}
|
以上代码是基于android判断手机是否是小米minu系统的方法,希望对大家有所帮助!