码迷,mamicode.com
首页 > 移动开发 > 详细

判断手机型号和cpu型号

时间:2014-10-30 15:23:16      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:android   型号   

<span style="font-size:18px;">判断手机型号:</span>
<span style="font-size:18px;">private boolean isUnusualPhone(){
		try {


			Class<?> cl = Class.forName("android.os.SystemProperties");


			Object invoker = cl.newInstance();


			Method m = cl.getMethod("get", new Class[] { String.class,
					String.class });


			Object result = m.invoke(invoker, new Object[] {
					"gsm.version.baseband", "no message" });
			return ((String) result).equals("I9250XXLJ1") || Build.MODEL.equals("MI 3");


		} catch (Exception e) {
			return true;
		}
	}</span>


判断手机cpu型号:

<span style="font-size:18px;">// android 2.3 for arm v5 yanqing
	public boolean hasCompatibleCPU() {
		// If already checked return cached result

		String CPU_ABI = android.os.Build.CPU_ABI;
		String CPU_ABI2 = "none";
		if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { // CPU_ABI2
			// since
			// 2.2
			try {
				CPU_ABI2 = (String) android.os.Build.class.getDeclaredField(
						"CPU_ABI2").get(null);
			} catch (Exception e) {
				return false;
			}
		}

		if (CPU_ABI.equals("armeabi-v7a") || CPU_ABI2.equals("armeabi-v7a")) {
			return true;
		}

		try {
			FileReader fileReader = new FileReader("/proc/cpuinfo");
			BufferedReader br = new BufferedReader(fileReader);
			String line;
			while ((line = br.readLine()) != null) {
				if (line.contains("ARMv7")) {
					return true;
				}

			}
			fileReader.close();
		} catch (IOException ex) {
			ex.printStackTrace();
			return false;
		}
		return false;
	}</span>


判断手机型号和cpu型号

标签:android   型号   

原文地址:http://blog.csdn.net/minenamewj/article/details/40619283

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!