廢話不多說了,直接給大家貼代碼了:
具體代碼如下所示:
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>//獲取緩存狀態(tài) 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系統(tǒng)的方法,希望對大家有所幫助!
新聞熱點
疑難解答
圖片精選