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

Android 获取手机设备等的信息

时间:2015-08-26 11:59:52      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:android

获取手机设备型号等信息:

如图华为P6手机获取是手机设备信息值:

技术分享

代码如下:

                tvStr = (TextView) findViewById(R.id.tv_titlebar);

		String phoneInfo = "Product: " + android.os.Build.PRODUCT + "\n";
		phoneInfo += "CPU_ABI: " + android.os.Build.CPU_ABI + "\n";
		phoneInfo += "TAGS: " + android.os.Build.TAGS + "\n";
		phoneInfo += "VERSION_CODES.BASE: "
				+ android.os.Build.VERSION_CODES.BASE + "\n";
		phoneInfo += "MODEL: " + android.os.Build.MODEL + "\n";
		phoneInfo += "SDK: " + android.os.Build.VERSION.SDK + "\n";
		phoneInfo += "VERSION.RELEASE: " + android.os.Build.VERSION.RELEASE
				+ "\n";
		phoneInfo += "DEVICE: " + android.os.Build.DEVICE + "\n";
		phoneInfo += "DISPLAY: " + android.os.Build.DISPLAY + "\n";
		phoneInfo += "BRAND: " + android.os.Build.BRAND + "\n";
		phoneInfo += "BOARD: " + android.os.Build.BOARD + "\n";
		phoneInfo += "FINGERPRINT: " + android.os.Build.FINGERPRINT + "\n";
		phoneInfo += "ID: " + android.os.Build.ID + "\n";
		phoneInfo += "MANUFACTURER: " + android.os.Build.MANUFACTURER + "\n";
		phoneInfo += "USER: " + android.os.Build.USER + "\n";

		// 这种方式在service中无法使用,
		DisplayMetrics dm = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(dm);
		int width = dm.widthPixels; // 宽
		int height = dm.heightPixels; // 高

		//在service中也能得到高和宽
		// WindowManager mWindowManager = (WindowManager)
		// getSystemService(Context.WINDOW_SERVICE);
		// width = mWindowManager.getDefaultDisplay().getWidth();
		// height = mWindowManager.getDefaultDisplay().getHeight();

		phoneInfo += "width: " + width + "\n";
		phoneInfo += "height: " + height;
		
		tvStr.setText(phoneInfo);



版权声明:本文为博主原创文章,未经博主允许不得转载。

Android 获取手机设备等的信息

标签:android

原文地址:http://blog.csdn.net/u012440207/article/details/48001209

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