【原】android获取设备基本信息

1、 android.os.Build.VERSION. RELEASE  获取用户当前android系统版本(如 4.1.1)

2、Locale.getDefault().getLanguage() 获取系统默认语言 如(zh)

3、 Locale.getDefault().getCountry() 获取系统设置当前国家 (CN)

4、  TelephonyManager telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
      telManager.getDeviceId() 获取设备ID

5、  String operator = telManager.getSimOperator();
    String ss="";
       if(operator!=null){
           if(operator.equals("46000")||operator.equals("46002")||operator.equals("46007")){
               ss="mobile";
       //中国移动
       }
           else if( operator.equals("46001")){
               ss="Unicom";
       //中国联通
       }else if( operator.equals("46003") ){
       //中国电信
           ss="CT";
       } 获取运营商
6、android.os.Build.MODEL 获取生产厂商

7、获取mac地址

String getMac() {
     String macSerial = null;
     String str = "";
     try {
             Process pp = Runtime.getRuntime().exec(
                             "cat /sys/class/net/wlan0/address ");
             InputStreamReader ir = new InputStreamReader(pp.getInputStream());
             LineNumberReader input = new LineNumberReader(ir);


             for (; null != str;) {
                     str = input.readLine();
                     if (str != null) {
                             macSerial = str.trim();// 去空格
                             break;
                     }
             }
     } catch (IOException ex) {
             // 赋予默认值
             ex.printStackTrace();
     }
     return macSerial;
}

8 获取当前上网环境

 ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);  
       NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();  
       String networkTypeString="";
       if(networkInfo.getType()==ConnectivityManager.TYPE_WIFI){
         //判断WIFI网
           networkTypeString="WIFI";
         }else if(networkInfo.getType()==ConnectivityManager.TYPE_MOBILE) {
         //判断3G网
             networkTypeString="MOBILE";
         }

9 获取屏幕大小

    (1)level 13之前

                 WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
                  int screenWidth=wm.getDefaultDisplay().getWidth();

     (2)level 13之后

            Point point=new Point();

            wm.getDefaultDisplay().getSize(point);

           point.x 屏幕宽

          point.y 屏幕高

posted @ 2013-03-28 15:29  U_探索  阅读(528)  评论(0编辑  收藏  举报