判断Android 系统是MIUI 的,魅族的Flyme ,还是原生的?
2016-03-30 16:09
459 查看
// 检测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; } } } // 检测Flyme import 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(); } }
作者:Mariotaku
链接:https://www.zhihu.com/question/22102139/answer/24834510
来源:知乎
相关文章推荐
- ios UITableView性能优化
- UUID生成方法总结
- UIview需要知道的一些事情:setNeedsDisplay、setNeedsLayout
- Android UI设计——EditText
- HBase源码分析之KeyValue
- QSqlQuery的使用
- Android RoboGuice 使用指南
- 对于requirejs AMD模块加载的理解
- JFinal教程JfinalUIB 代码笔记 (9)--- JFinal分页存在的问题
- Android 之200款UI效果
- UIBarButtonSystemItem样式一览
- druid报异常 “sql injection violation, part alway true condition not allow”的解决方案
- not unique tables/alias:'t_cms_queen'
- 【iOS开发新手上路】教你一步一步创建一个功能齐全的UITableViewController(上)
- iOS中UITableView的UITableViewStyleGrouped组间距
- 放肆地使用UIBezierPath和CAShapeLayer画各种图形
- GPUImage
- MySQL query_cache_type 详解
- lightoj 1126 - Building Twin Towers DP
- easy ui 隐藏textbox