1、获取手机制造厂商
2、获取手机型号
3、获取手机系统当前使用的语言
4、获取Android系统版本号
5、获取手机IMEI串号
6、获取手机中的语言列表
SystemUtil类
1.
/**
2.
* 系统工具类
3.
* Created by zhuwentao on 2016-07-18.
4.
*/
5. public class SystemUtil {
6.
7.
/**
8.
* 获取当前手机系统语言。
9.
*
10. * @return 返回当前系统语言。例如:当前设置的是“中文-中国”,则返回“zh-CN”
11. */
12. public static String getSystemLanguage() {
13. return Locale.getDefault().getLanguage();
14. }
15.
16. /**
17. * 获取当前系统上的语言列表(Locale列表)
18. *
19. * @return 语言列表
20. */
21. public static Locale[] getSystemLanguageList() {
22. return Locale.getAvailableLocales();
23. }
24.
25. /**
26. * 获取当前手机系统版本号
27. *
28. * @return 系统版本号
29. */
30. public static String getSystemVersion() {
31. return android.os.Build.VERSION.RELEASE;
32. }
33.
34. /**
35. * 获取手机型号
36. *
37. * @return 手机型号
38. */
39. public static String getSystemModel() {
40. return android.os.Build.MODEL;
41. }
42.
43. /**
44. * 获取手机厂商
45. *
46. * @return 手机厂商
47. */
48. public static String getDeviceBrand() {
49. return android.os.Build.BRAND;
50. }
51.
52. /**
53. * 获取手机IMEI(需要“android.permission.READ_PHONE_STATE”权限)
54. *
55. * @return 手机IMEI
56. */
57. public static String getIMEI(Context ctx) {
58. TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Activity.TELEPHONY_SERVICE);
59. if (tm != null) {
60. return tm.getDeviceId();
61. }
62. return null;
63. }
64. }
其中获取手机IMEI需要在AndroidManifest.xml中加上权限:
1. android:name="android.permission.READ_PHONE_STATE" />
使用这些方法的时候直接调用就好了
1. private void showSystemParameter() {
2.
String TAG = "系统参数:";
3.
Log.e(TAG, "手机厂商:" + SystemUtil.getDeviceBrand());
4.
Log.e(TAG, "手机型号:" + SystemUtil.getSystemModel());
5.
Log.e(TAG, "手机当前系统语言:" + SystemUtil.getSystemLanguage());
6.
Log.e(TAG, "Android系统版本号:" + SystemUtil.getSystemVersion());
7.
Log.e(TAG, "手机IMEI:" + SystemUtil.getIMEI(getApplicationContext()));
8.
}
返回结果:
IMEI号,IESI号,手机型号:
privatevoidgetInfo() {
TelephonyManager mTm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
String imei = mTm.getDeviceId();
String imsi = mTm.getSubscriberId();
String mtype = android.os.Build.MODEL; // 手机型号
String numer = mTm.getLine1Number(); // 手机号码,有的可得,有的不可得
}
手机型号 Build.MODEL
The end-user-visible name for the end product.
sdk版本 Build.VERSION.SDK
This constant is deprecated. Use SDK_INT to easily get this as an integer.
及frimware版本号(系统版本号) Build.VERSION.RELEASE
The user-visible version string.
事实上,Build能向我们提供包括 硬件厂商,硬件编号,序列号等很多信息 调用方法也都同上,很简单。
The name of the underlying board, like "goldfish".
The system bootloader version number.
The brand (e.g., carrier) the software is customized for, if any.
The name of the instruction set (CPU type + ABI convention) of native code.
The name of the second instruction set (CPU type + ABI convention) of native code.
The name of the industrial design.
A build ID string meant for displaying to the user
A string that uniquely identifies this build.
The name of the hardware (from the kernel command line or /proc).
Either a changelist number, or a label like "M4-rc20".
The manufacturer of the product/hardware.
The end-user-visible name for the end product.
The name of the overall product.
The radio firmware version number.
A hardware serial number, if available.
Comma-separated tags describing the build, like "unsigned,debug".
long
The type of build, like "user" or "eng".
Value used for when a build property is unknown.
明确几个概念:
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操作的函数获得。
记得添加权限:
Android:name="android.permission.READ_PHONE_STATE" />
获取手机屏幕高度:
privatevoidgetWeithAndHeight(){
//这种方式在service中无法使用,
DisplayMetrics dm = newDisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
String width = dm.widthPixels; //宽
String height = dm.heightPixels; //高
//在service中也能得到高和宽
WindowManager mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
width = mWindowManager.getDefaultDisplay().getWidth();
height = mWindowManager.getDefaultDisplay().getHeight();
}
获取手机MAC地址:
privateString getMacAddress(){
String result = "";
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
result = wifiInfo.getMacAddress();
Log.i(TAG, "macAdd:"+ result);
returnresult;
}
手机CPU信息
privateString[] getCpuInfo() {
String str1 = "/proc/cpuinfo";
String str2 = "";
String[] cpuInfo = {"",""};//1-cpu型号 //2-cpu频率
String[] arrayOfString;
try{
FileReader fr = newFileReader(str1);
BufferedReader localBufferedReader = newBufferedReader(fr,8192);
str2 = localBufferedReader.readLine();
arrayOfString = str2.split("\\s+");
for(inti =2; i < arrayOfString.length; i++) {
cpuInfo[0] = cpuInfo[0] + arrayOfString[i] +" ";
}
str2 = localBufferedReader.readLine();
arrayOfString = str2.split("\\s+");
cpuInfo[1] += arrayOfString[2];
localBufferedReader.close();
} catch(IOException e) {
}
Log.i(TAG, "cpuinfo:"+ cpuInfo[0] +" "+ cpuInfo[1]);
returncpuInfo;
}
网上收集的一些获取收集信息的代码,制作成一个工具类,以后可以方便调用。