android获取手机信息大全

来源:互联网 发布:软件国产化 概念 编辑:程序博客网 时间:2024/05/22 08:17

IMEI号,IESI号,手机型号:

[java] view plaincopyprint?
  1. private void getInfo() {    
  2.              TelephonyManager mTm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);    
  3.              String imei = mTm.getDeviceId();    
  4.              String imsi = mTm.getSubscriberId();    
  5.              String mtype = android.os.Build.MODEL; // 手机型号    
  6.              String numer = mTm.getLine1Number(); // 手机号码,有的可得,有的不可得    
  7.          }  

手机型号 Build.MODEL

StringMODELThe end-user-visible name for the end product.

sdk版本 Build.VERSION.SDK

StringSDKThis constant is deprecated. Use SDK_INT to easily get this as an integer.

及frimware版本号(系统版本号) Build.VERSION.RELEASE

StringRELEASEThe user-visible version string.

事实上,Build能向我们提供包括 硬件厂商,硬件编号,序列号等很多信息 调用方法也都同上,很简单。

StringBOARDThe name of the underlying board, like "goldfish".StringBOOTLOADERThe system bootloader version number.StringBRANDThe brand (e.g., carrier) the software is customized for, if any.StringCPU_ABIThe name of the instruction set (CPU type + ABI convention) of native code.StringCPU_ABI2The name of the second instruction set (CPU type + ABI convention) of native code.StringDEVICEThe name of the industrial design.StringDISPLAYA build ID string meant for displaying to the userStringFINGERPRINTA string that uniquely identifies this build.StringHARDWAREThe name of the hardware (from the kernel command line or /proc).StringHOST StringIDEither a changelist number, or a label like "M4-rc20".StringMANUFACTURERThe manufacturer of the product/hardware.StringMODELThe end-user-visible name for the end product.StringPRODUCTThe name of the overall product.StringRADIOThe radio firmware version number.StringSERIALA hardware serial number, if available.StringTAGSComma-separated tags describing the build, like "unsigned,debug".longTIME StringTYPEThe type of build, like "user" or "eng".StringUNKNOWNValue used for when a build property is unknown.StringUSER

明确几个概念:

 

SIM卡存储的数据可分为四类:

第一类是固定存放的数据。这类数据在移动电话机被出售之前由SIM卡中心写入,包括国际移动用户识别号(IMSI)、鉴权密钥(KI)、鉴权和加密算法等等。

第二类是暂时存放的有关网络的数据。如位置区域识别码(LAI)、移动用户暂时识别码(TMSI)、禁止接入的公共电话网代码等。

第三类是相关的业务代码,如个人识别码(PIN)、解锁码(PUK)、计费费率等。

第四类是电话号码簿,是手机用户随时输入的电话号码。用户全部资料几乎都存储在SIM卡内,因此SIM卡又称为用户资料识别卡。

 

IMSI是一个唯一的数字, 标识了GSM和UMTS 网络里的唯一一个用户. 它存储 在手机的SIM卡里,它会通过手机发送到网络上. IMSI 与 SIM唯一对应

IMEI也是一串唯一的数字, 标识了 GSM 和 UMTS网络里的唯一一个手机.它通常被打印在手机里电池下面的那一面,拨 *#06# 也能看到它. IMEI 与 设备唯一对应.

1。IMEI不存在于SIM卡中,它是手机本身的串号。 
2。通常我们所说的手机号也不存在于SIM卡中,虽然SIM卡中有一个专门存储SIM卡本身号码的地方,但是此号码是通过手工设定的,而且是可以更改的。 SIM卡的识别通常使用IMSI号,这个对于SIM卡是唯一的。 
3。使用SimGetRecordInfo之类的函数获得SIM卡的IMSI号码能否成功依赖于设备制造商是否实现了此函数,据我所知在DOPOD的机器上是可以获得,但是在联想的机器上却不行,其他机器没有。 
4。获得IMEI以及IMSI可以通过RIL或者TAPI中的LINE操作的函数获得。


记得添加权限:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />


获取手机屏幕高度:

[java] view plaincopyprint?
  1. private void getWeithAndHeight(){    
  2.             //这种方式在service中无法使用,    
  3.             DisplayMetrics dm = new DisplayMetrics();    
  4.             getWindowManager().getDefaultDisplay().getMetrics(dm);    
  5.             String width = dm.widthPixels;              //宽    
  6.             String height = dm.heightPixels;           //高    
  7.          
  8.             //在service中也能得到高和宽    
  9.             WindowManager mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);    
  10.             width = mWindowManager.getDefaultDisplay().getWidth();    
  11.             height = mWindowManager.getDefaultDisplay().getHeight();    
  12.         }  


获取手机MAC地址:

[java] view plaincopyprint?
  1. private String getMacAddress(){    
  2.              String result = "";    
  3.              WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);    
  4.              WifiInfo wifiInfo = wifiManager.getConnectionInfo();    
  5.              result = wifiInfo.getMacAddress();    
  6.              Log.i(TAG, "macAdd:" + result);    
  7.              return result;    
  8.      }  

手机CPU信息

[java] view plaincopyprint?
  1. private String[] getCpuInfo() {    
  2.              String str1 = "/proc/cpuinfo";    
  3.              String str2 = "";    
  4.              String[] cpuInfo = {""""};  //1-cpu型号  //2-cpu频率    
  5.              String[] arrayOfString;    
  6.              try {    
  7.                  FileReader fr = new FileReader(str1);    
  8.                  BufferedReader localBufferedReader = new BufferedReader(fr, 8192);    
  9.                  str2 = localBufferedReader.readLine();    
  10.                  arrayOfString = str2.split("\\s+");    
  11.                  for (int i = 2; i < arrayOfString.length; i++) {    
  12.                      cpuInfo[0] = cpuInfo[0] + arrayOfString[i] + " ";    
  13.                  }    
  14.                  str2 = localBufferedReader.readLine();    
  15.                  arrayOfString = str2.split("\\s+");    
  16.                  cpuInfo[1] += arrayOfString[2];    
  17.                  localBufferedReader.close();    
  18.              } catch (IOException e) {    
  19.              }    
  20.              Log.i(TAG, "cpuinfo:" + cpuInfo[0] + " " + cpuInfo[1]);    
  21.              return cpuInfo;    
  22.          }  

获取手机可用内存和总内存:

[java] view plaincopyprint?
  1. private String[] getTotalMemory() {    
  2.             String[] result = {"",""};  //1-total 2-avail    
  3.             ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();      
  4.             mActivityManager.getMemoryInfo(mi);      
  5.             long mTotalMem = 0;    
  6.             long mAvailMem = mi.availMem;    
  7.             String str1 = "/proc/meminfo";    
  8.             String str2;    
  9.             String[] arrayOfString;    
  10.             try {    
  11.                 FileReader localFileReader = new FileReader(str1);    
  12.                 BufferedReader localBufferedReader = new BufferedReader(localFileReader, 8192);    
  13.                 str2 = localBufferedReader.readLine();    
  14.                 arrayOfString = str2.split("\\s+");    
  15.                 mTotalMem = Integer.valueOf(arrayOfString[1]).intValue() * 1024;    
  16.                 localBufferedReader.close();    
  17.             } catch (IOException e) {    
  18.                 e.printStackTrace();    
  19.             }    
  20.             result[0] = Formatter.formatFileSize(this, mTotalMem);    
  21.             result[1] = Formatter.formatFileSize(this, mAvailMem);    
  22.             Log.i(TAG, "meminfo total:" + result[0] + " used:" + result[1]);    
  23.             return result;    
  24.         }  

获取手机安装的应用信息(排除系统自带):

[java] view plaincopyprint?
  1. private String getAllApp() {    
  2.              String result = "";    
  3.              List<PackageInfo> packages = getPackageManager().getInstalledPackages(0);    
  4.              for (PackageInfo i : packages) {    
  5.                  if ((i.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {    
  6.                      result += i.applicationInfo.loadLabel(getPackageManager()).toString() + ",";    
  7.                  }    
  8.              }    
  9.              return result.substring(0, result.length() - 1);    
  10.      }  
0 0
原创粉丝点击