日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android 判断手机为小米

發布時間:2024/4/15 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android 判断手机为小米 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

??????? 之前,自己寫了獲取相冊圖片的代碼,在自己手機上測試沒有問題,不過小米手機卻出現問題。在網上搜索資料,發現小米手機與其他德 處理不同。所以今天寫一下判斷手機系統的內容。其實很簡單。


public static final String SYS_EMUI = "sys_emui";public static final String SYS_MIUI = "sys_miui";public static final String SYS_FLYME = "sys_flyme";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";private static final String KEY_EMUI_API_LEVEL = "ro.build.hw_emui_api_level";private static final String KEY_EMUI_VERSION = "ro.build.version.emui";private static final String KEY_EMUI_CONFIG_HW_SYS_VERSION = "ro.confg.hw_systemversion";public static String getSystem(){String SYS;try {Properties prop= new Properties();prop.load(new FileInputStream(new File(Environment.getRootDirectory(), "build.prop")));if(prop.getProperty(KEY_MIUI_VERSION_CODE, null) != null|| prop.getProperty(KEY_MIUI_VERSION_NAME, null) != null|| prop.getProperty(KEY_MIUI_INTERNAL_STORAGE, null) != null){SYS = SYS_MIUI;//小米}else if(prop.getProperty(KEY_EMUI_API_LEVEL, null) != null||prop.getProperty(KEY_EMUI_VERSION, null) != null||prop.getProperty(KEY_EMUI_CONFIG_HW_SYS_VERSION, null) != null){SYS = SYS_EMUI;//華為}else if(getMeizuFlymeOSFlag().toLowerCase().contains("flyme")){SYS = SYS_FLYME;//魅族};} catch (IOException e){e.printStackTrace();return SYS;}return SYS;}public static String getMeizuFlymeOSFlag() {return getSystemProperty("ro.build.display.id", "");}private static String getSystemProperty(String key, String defaultValue) {try {Class<?> clz = Class.forName("android.os.SystemProperties");Method get = clz.getMethod("get", String.class, String.class);return (String)get.invoke(clz, key, defaultValue);} catch (Exception e) {}return defaultValue;}


主要是獲取build.prop文件的內容,然后獲取的信息與那個手機的系統信息想符合,就是哪種手機。判斷的依據是prop.getProperty(),里面的參數每個手機都不一樣,只要一個手機的返回值不為null,那么就可以判斷手機類型。


android 判斷手機為小米就講完了。


就這么簡單。




總結

以上是生活随笔為你收集整理的android 判断手机为小米的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。