获取设备(Device)操作

/**
         * 获得设备型号
         * @return
         */
        public static String getDeviceModel() {
        return Build.MODEL;
    }
        
        /**
         * 获得国际移动设备身份码
         * @param context
         * @return
         */
        public static String getIMEI(Context context) {
        return ((TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
    }
        
        /**
         * 获得国际移动用户识别码
         * @param context
         * @return
         */
        public static String getIMSI(Context context) {
        return ((TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE)).getSubscriberId();
    }
        
        /**
         * 获得设备屏幕矩形区域范围
         * @param context
         * @return
         */
        public static Rect getScreenRect(Context context) {
        Display display = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        int w = display.getWidth();
        int h = display.getHeight();
        return new Rect(0, 0, w, h);
    }
        
        /**
         * 获得设备屏幕密度
         */
        public static float getScreenDensity(Context context) {
                DisplayMetrics metrics = context.getApplicationContext().getResources().getDisplayMetrics();
                return metrics.density;
        }
        
        /** 
         * 获得系统版本
         */
        public static String getSDKVersion(){
                
                return android.os.Build.VERSION.SDK;
        }
        
        public static int getSDKVersionInt(){
                return NumberUtil.toInt(android.os.Build.VERSION.SDK);
        }



你可能感兴趣的:(android,util,device)