获取手机版本,手机型号,系统版本,手机设备唯一序列号,手机应用版本,手机网络类型的总结

来源:互联网 发布:手机怎么注册淘宝网店 编辑:程序博客网 时间:2024/05/01 19:38

手机设备的唯一序列号

public static String getDeviceInfo(Context context) {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        return tm.getDeviceId();

    }

"软件版本"

public  String getVersion(){
        
        PackageManager manager = getPackageManager();
        
        try {
            info = manager.getPackageInfo(this.getPackageName(), 0);
        } catch (NameNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return info.versionName;
        
    }

/** * 检查网络连接类型 *  * @param context * @return int 0既没有wifi也没有mobile 1 为wifi 2 为mobile */public static int checkNetworkType(Context context) {   boolean wifiConnected;   boolean mobileConnected;   short type = 0;// 0既没有wifi也没有mobile 1 为wifi 2 为mobile   ConnectivityManager connMgr = (ConnectivityManager) context         .getSystemService(Context.CONNECTIVITY_SERVICE);   NetworkInfo activeInfo = connMgr.getActiveNetworkInfo();   if (activeInfo != null && activeInfo.isConnected()) {      wifiConnected = activeInfo.getType() == ConnectivityManager.TYPE_WIFI;      mobileConnected = activeInfo.getType() == ConnectivityManager.TYPE_MOBILE;      if (wifiConnected) {         type = 1;      } else if (mobileConnected) {         type = 2;      }   }   return type;}/** * 检查网络连接类型 * * @param context * @return int 0既没有wifi也没有mobile 1 为wifi 2 为mobile */public static String getNetState(Context context) {   ConnectivityManager connMgr = (ConnectivityManager) context         .getSystemService(Context.CONNECTIVITY_SERVICE);   NetworkInfo activeInfo = connMgr.getActiveNetworkInfo();   if (activeInfo != null && activeInfo.isConnected()) {      return activeInfo.getState()+activeInfo.getExtraInfo()+activeInfo.getType();   }   return null;}/** 获取手机网络状态 2G 3G等等* */public static String getCurrentNetType(Context context) {   String type = "";   ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);   NetworkInfo info = cm.getActiveNetworkInfo();   if (info == null) {      type = "null";   } else if (info.getType() == ConnectivityManager.TYPE_WIFI) {      type = "wifi";   } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {      int subType = info.getSubtype();      if (subType == TelephonyManager.NETWORK_TYPE_CDMA || subType == TelephonyManager.NETWORK_TYPE_GPRS            || subType == TelephonyManager.NETWORK_TYPE_EDGE) {         type = "2g";      } else if (subType == TelephonyManager.NETWORK_TYPE_UMTS || subType == TelephonyManager.NETWORK_TYPE_HSDPA            || subType == TelephonyManager.NETWORK_TYPE_EVDO_A || subType == TelephonyManager.NETWORK_TYPE_EVDO_0            || subType == TelephonyManager.NETWORK_TYPE_EVDO_B) {         type = "3g";      } else if (subType == TelephonyManager.NETWORK_TYPE_LTE) {// LTE是3g到4g的过渡,是3.9G的全球标准         type = "4g";      }   }   return type;}/** * 检查网络是否连接 *  * @param context * @return true连接 false非连接 */public static boolean checkConnected(Context context) {   boolean b = false;   ConnectivityManager connMgr = (ConnectivityManager) context         .getSystemService(Context.CONNECTIVITY_SERVICE);   NetworkInfo activeInfo = connMgr.getActiveNetworkInfo();   if (activeInfo != null && activeInfo.isConnected()) {      int type = activeInfo.getType();      if (type == ConnectivityManager.TYPE_WIFI) {         b = true;      } else if (type == ConnectivityManager.TYPE_MOBILE) {         b = true;      }   }   return b;}/** * 判断当前网络是否为wifi *  * @param mContext * @return */public static boolean isWifi(Context mContext) {   ConnectivityManager connMgr = (ConnectivityManager) mContext         .getSystemService(Context.CONNECTIVITY_SERVICE);   NetworkInfo activeNetInfo = connMgr.getActiveNetworkInfo();   return activeNetInfo != null         && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI;}

        //获取手机系统版本
    "手机系统版本",                        android.os.Build.VERSION.SDK);
        "手机系统版本----4.4.4",         android.os.Build.VERSION.RELEASE;

        "手机型号",                               android.os.Build.MODEL;

     手机品牌                          android.os.Build.BRAND; 

0 0
原创粉丝点击