读取手机参数

手机操作系统版本获取

public static int getSDKVersionNumber() {
		int sdkVersion;
		try {
			sdkVersion = Integer.valueOf(android.os.Build.VERSION.SDK_INT);
			Log.i("eee", "sdkver:" + sdkVersion);
		} catch (NumberFormatException e) {
			sdkVersion = 0;
		}

		return sdkVersion;
	}

 

手机的一些屏幕参数:

/**
     * get mobile phone screen info
     */
    public void getScreenInfo(){
    	WindowManager win = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
    	Display d= win.getDefaultDisplay();
    	int w = d.getWidth();				// 宽度
    	int h=d.getHeight();				// 高度
    	int or=d.getOrientation();			// 0代表portrait,1代表landscape
    	int pformat=d.getPixelFormat();		// pixel format :sdk 文档public static final int RGBA_8888 (0x00000001)
    	float frames=d.getRefreshRate();	// 刷新频率frames per second每秒多少帧
    	int rotation=d.getRotation();		// 旋转度数。1代表旋转90度。Returns the rotation of the screen from its "natural" orientation
    	String str = "width: "+w+" height: "+h+" orientation: "+or
    			+" pixelFormat: "+pformat+" refreshRate: "+frames+" rotation: "+rotation;
    	System.out.println(str);
    }


 结果:

01-16 18:09:43.336: I/System.out(24171): portrait竖屏
width: 480
height: 854
orientation: 0
pixelFormat: 1
refreshRate: 0.012
rotation: 0


01-16 18:11:32.586: I/System.out(24171): landscape横屏
width: 854
height: 480
orientation: 1
pixelFormat: 1
refreshRate: 0.012               值等于83.3333333,每秒钟约刷新83次
rotation: 1

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值