判断Android 系统是MIUI 的,魅族的Flyme(转,做笔记)
2015-06-03 11:16
686 查看
// 检测MIUI import java.io.IOException; public final class MIUIUtils { 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() { try { final BuildProperties prop = BuildProperties.newInstance(); return prop.getProperty(KEY_MIUI_VERSION_CODE, null) != null || prop.getProperty(KEY_MIUI_VERSION_NAME, null) != null || prop.getProperty(KEY_MIUI_INTERNAL_STORAGE, null) != null; } catch (final IOException e) { return false; } }}// 检测Flymeimport android.os.Build;import java.lang.reflect.Method;public final class FlymeUtils { public static boolean isFlyme() { try { // Invoke Build.hasSmartBar() final Method method = Build.class.getMethod("hasSmartBar"); return method != null; } catch (final Exception e) { return false; } }}//引用到的工具类 import android.os.Environment; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Collection; import java.util.Enumeration; import java.util.Map.Entry; import java.util.Properties; import java.util.Set;public class BuildProperties { private final Properties properties; private BuildProperties() throws IOException { properties = new Properties(); properties.load(new FileInputStream(new File(Environment.getRootDirectory(), "build.prop"))); } public boolean containsKey(final Object key) { return properties.containsKey(key); } public boolean containsValue(final Object value) { return properties.containsValue(value); } public Set<Entry<Object, Object>> entrySet() { return properties.entrySet(); } public String getProperty(final String name) { return properties.getProperty(name); } public String getProperty(final String name, final String defaultValue) { return properties.getProperty(name, defaultValue); } public boolean isEmpty() { return properties.isEmpty(); } public Enumeration<Object> keys() { return properties.keys(); } public Set<Object> keySet() { return properties.keySet(); } public int size() { return properties.size(); } public Collection<Object> values() { return properties.values(); } public static BuildProperties newInstance() throws IOException { return new BuildProperties(); }}
相关文章推荐
- Android进程与线程基本知识
- 【Android 一般进阶】动态广播注册注销时机
- Android进步之路九:Handler出现的原因,特点以及实例
- Android 圆形ImageView
- Android Fragment制作Tab
- android应用程序如何调用支付宝接口
- 使用Android简单实现有道电子词典
- 使用Android简单实现有道电子词典
- Mac OS下Android Studio 新安装或者更新版本之后不能启动问题解决
- Android支付-银联支付
- Android,LIstView中的OnItemClick点击无效的解决办法
- android应用程序如何调用支付宝接口
- phonegap5.0+android studio本地打包应用
- 【翻译】Android DEX安全攻防战
- jni开发中打印log信息
- Android 模块化编程之引用本地的 aar
- android中dip、dp、px、sp和屏幕密度
- Android平台编译小技巧
- [置顶] Android Device Chooser 找不到真机设备问题
- Android学习 - Service被关闭后自动重启,解决被异常kill 服务