Android如何判断MIUI和魅族手机
2016-07-05 09:42
253 查看
最近项目里要对MIUI手机的推送做特殊处理,走小米平台的推送,所以要区分下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; } } } import android.os.Build; import java.lang.reflect.Method; public final class FlymeUtils { public static boolean isFlyme() { try { 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(); } }
相关文章推荐
- UnicodeDecodeError: ‘XXX’ codec can’t decode bytes in position 2-5: illegal multibyte sequence
- iOS App开发中通过UIDevice类获取设备信息的方法
- UIView的setNeedsLayout,layoutIfNeeded,layoutSubviews 方法之间的关系解释
- 动态库、竖屏显示
- Error:Execution failed for task ':clean'. > Unable to delete directory :\build\intermediates
- Autolayout在UITableView中的坑
- UITableView详解
- UIButton详解
- PowerBuilder安装及破解教程
- PAT (Advanced Level) 1101. Quick Sort (25)
- php中使用include(require)嵌套包含文件时的一些注意问题
- PAT (Advanced Level) 1099. Build A Binary Search Tree (30)
- Shortest Distance from All Buildings
- 源码推荐(0705):简仿映客直播App,UITableView右侧索引
- geeksforgeeks@ Sorting Elements of an Array by Frequency (Sort)
- Longest Consecutive Sequence
- HTML标签marquee实现滚动效果
- APUE(5)---标准I/O库 (3)
- JS与HTML结合使用marquee标签实现无缝滚动效果代码
- UIScrollView截取内部内容存入相册