android获取操作系统版本号,Android 获取手机的厂商、型号、Android系统版本号、IMEI、当前系统语言等工具类...
1、獲取手機(jī)制造廠商
2、獲取手機(jī)型號(hào)
3、獲取手機(jī)系統(tǒng)當(dāng)前使用的語言
4、獲取Android系統(tǒng)版本號(hào)
5、獲取手機(jī)IMEI串號(hào)
6、獲取手機(jī)中的語言列表
SystemUtil類
1.
/**
2.
*?系統(tǒng)工具類
3.
*?Created?by?zhuwentao?on?2016-07-18.
4.
*/
5. public class SystemUtil?{
6.
7.
/**
8.
*?獲取當(dāng)前手機(jī)系統(tǒng)語言。
9.
*
10.? ?????*?@return?返回當(dāng)前系統(tǒng)語言。例如:當(dāng)前設(shè)置的是“中文-中國”,則返回“zh-CN”
11.? ?????*/
12. public static String?getSystemLanguage()?{
13. return Locale.getDefault().getLanguage();
14.? ????}
15.
16.? ????/**
17.? ?????*?獲取當(dāng)前系統(tǒng)上的語言列表(Locale列表)
18.? ?????*
19.? ?????*?@return??語言列表
20.? ?????*/
21. public static Locale[]?getSystemLanguageList()?{
22. return Locale.getAvailableLocales();
23.? ????}
24.
25.? ????/**
26.? ?????*?獲取當(dāng)前手機(jī)系統(tǒng)版本號(hào)
27.? ?????*
28.? ?????*?@return??系統(tǒng)版本號(hào)
29.? ?????*/
30. public static String?getSystemVersion()?{
31. return android.os.Build.VERSION.RELEASE;
32.? ????}
33.
34.? ????/**
35.? ?????*?獲取手機(jī)型號(hào)
36.? ?????*
37.? ?????*?@return??手機(jī)型號(hào)
38.? ?????*/
39. public static String?getSystemModel()?{
40. return android.os.Build.MODEL;
41.? ????}
42.
43.? ????/**
44.? ?????*?獲取手機(jī)廠商
45.? ?????*
46.? ?????*?@return??手機(jī)廠商
47.? ?????*/
48. public static String?getDeviceBrand()?{
49. return android.os.Build.BRAND;
50.? ????}
51.
52.? ????/**
53.? ?????*?獲取手機(jī)IMEI(需要“android.permission.READ_PHONE_STATE”權(quán)限)
54.? ?????*
55.? ?????*?@return??手機(jī)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.? }
其中獲取手機(jī)IMEI需要在AndroidManifest.xml中加上權(quán)限:
1. android:name="android.permission.READ_PHONE_STATE" />
使用這些方法的時(shí)候直接調(diào)用就好了
1. private void showSystemParameter()?{
2.
String?TAG?=?"系統(tǒng)參數(shù):";
3.
Log.e(TAG,?"手機(jī)廠商:"?+?SystemUtil.getDeviceBrand());
4.
Log.e(TAG,?"手機(jī)型號(hào):"?+?SystemUtil.getSystemModel());
5.
Log.e(TAG,?"手機(jī)當(dāng)前系統(tǒng)語言:"?+?SystemUtil.getSystemLanguage());
6.
Log.e(TAG,?"Android系統(tǒng)版本號(hào):"?+?SystemUtil.getSystemVersion());
7.
Log.e(TAG,?"手機(jī)IMEI:"?+?SystemUtil.getIMEI(getApplicationContext()));
8.
}
返回結(jié)果:
IMEI號(hào),IESI號(hào),手機(jī)型號(hào):
privatevoidgetInfo()?{
TelephonyManager?mTm?=?(TelephonyManager)?getSystemService(TELEPHONY_SERVICE);
String?imei?=?mTm.getDeviceId();
String?imsi?=?mTm.getSubscriberId();
String?mtype?=?android.os.Build.MODEL; //?手機(jī)型號(hào)
String?numer?=?mTm.getLine1Number(); //?手機(jī)號(hào)碼,有的可得,有的不可得
}
手機(jī)型號(hào) 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版本號(hào)(系統(tǒng)版本號(hào))?Build.VERSION.RELEASE
The user-visible version string.
事實(shí)上,Build能向我們提供包括 硬件廠商,硬件編號(hào),序列號(hào)等很多信息 調(diào)用方法也都同上,很簡單。
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.
明確幾個(gè)概念:
SIM卡存儲(chǔ)的數(shù)據(jù)可分為四類:
第一類是固定存放的數(shù)據(jù)。這類數(shù)據(jù)在移動(dòng)電話機(jī)被出售之前由SIM卡中心寫入,包括國際移動(dòng)用戶識(shí)別號(hào)(IMSI)、鑒權(quán)密鑰(KI)、鑒權(quán)和加密算法等等。
第二類是暫時(shí)存放的有關(guān)網(wǎng)絡(luò)的數(shù)據(jù)。如位置區(qū)域識(shí)別碼(LAI)、移動(dòng)用戶暫時(shí)識(shí)別碼(TMSI)、禁止接入的公共電話網(wǎng)代碼等。
第三類是相關(guān)的業(yè)務(wù)代碼,如個(gè)人識(shí)別碼(PIN)、解鎖碼(PUK)、計(jì)費(fèi)費(fèi)率等。
第四類是電話號(hào)碼簿,是手機(jī)用戶隨時(shí)輸入的電話號(hào)碼。用戶全部資料幾乎都存儲(chǔ)在SIM卡內(nèi),因此SIM卡又稱為用戶資料識(shí)別卡。
IMSI是一個(gè)唯一的數(shù)字, 標(biāo)識(shí)了GSM和UMTS?網(wǎng)絡(luò)里的唯一一個(gè)用戶.?它存儲(chǔ) 在手機(jī)的SIM卡里,它會(huì)通過手機(jī)發(fā)送到網(wǎng)絡(luò)上.?IMSI?與?SIM唯一對(duì)應(yīng)
IMEI也是一串唯一的數(shù)字, 標(biāo)識(shí)了?GSM?和?UMTS網(wǎng)絡(luò)里的唯一一個(gè)手機(jī).它通常被打印在手機(jī)里電池下面的那一面,撥?*#06#?也能看到它.?IMEI?與?設(shè)備唯一對(duì)應(yīng).
1。IMEI不存在于SIM卡中,它是手機(jī)本身的串號(hào)。
2。通常我們所說的手機(jī)號(hào)也不存在于SIM卡中,雖然SIM卡中有一個(gè)專門存儲(chǔ)SIM卡本身號(hào)碼的地方,但是此號(hào)碼是通過手工設(shè)定的,而且是可以更改的。?SIM卡的識(shí)別通常使用IMSI號(hào),這個(gè)對(duì)于SIM卡是唯一的。
3。使用SimGetRecordInfo之類的函數(shù)獲得SIM卡的IMSI號(hào)碼能否成功依賴于設(shè)備制造商是否實(shí)現(xiàn)了此函數(shù),據(jù)我所知在DOPOD的機(jī)器上是可以獲得,但是在聯(lián)想的機(jī)器上卻不行,其他機(jī)器沒有。
4。獲得IMEI以及IMSI可以通過RIL或者TAPI中的LINE操作的函數(shù)獲得。
記得添加權(quán)限:
Android:name="android.permission.READ_PHONE_STATE" />
獲取手機(jī)屏幕高度:
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();
}
獲取手機(jī)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;
}
手機(jī)CPU信息
privateString[]?getCpuInfo()?{
String?str1?= "/proc/cpuinfo";
String?str2?= "";
String[]?cpuInfo?=?{"",""};//1-cpu型號(hào)??//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;
}
網(wǎng)上收集的一些獲取收集信息的代碼,制作成一個(gè)工具類,以后可以方便調(diào)用。
總結(jié)
以上是生活随笔為你收集整理的android获取操作系统版本号,Android 获取手机的厂商、型号、Android系统版本号、IMEI、当前系统语言等工具类...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 天津科技大学计算机网络,计算机网络PPT
- 下一篇: 三星s10能升级android11,三星