读取手机参数

来源:互联网 发布:用c语言输出九九乘法表 编辑:程序博客网 时间:2024/04/28 16:32

手机操作系统版本获取

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

 

原创粉丝点击