1.2.2.2 system information
InAndroidTo obtain system information, you can call the provided method system. getproperty (propertystr), and system information such as the user root directory (user. home) and so on can be obtained through this method, the implementation code is as follows:
Java code:
Public static stringbuffer buffer = NULL;
Private Static string initproperty (string description, string propertystr ){
If (buffer = NULL ){
Buffer = new stringbuffer ();
}
Buffer. append (description). append (":");
Buffer. append (system. getproperty (propertystr). append ("");
Return buffer. tostring ();
}
Private Static string getsystemproperty (){
Buffer = new stringbuffer ();
Initproperty ("Java. Vendor. url", "Java. Vendor. url ");
Initproperty ("Java. Class. Path", "Java. Class. Path ");
Return buffer. tostring ();
}
The above code mainly obtains the specified system information by calling the system. getproperty method provided by the system, and combines the information into a string for return.
1.2.2.3 carrier Information
The carrier information includes the IMEI and mobile phone number.AndroidProvides the operator management class (telephonymanager). You can use telephonymanager to obtain carrier-related information. The key code for implementation is as follows:
Java code:
Public static string fetch_tel_status (context CX ){
String result = NULL;
Telephonymanager TM = (telephonymanager) Cx. getsystemservice (context. telephony_service );
String STR = "";
STR + = "DeviceID (IMEI) =" + TM. getdeviceid () + "";
STR + = "devicesoftwareversion =" + TM. getdevicesoftwareversion () + "";
// Todo: Do something...
Int MCC = Cx. getresources (). getconfiguration (). MCC;
Int MNC = Cx. getresources (). getconfiguration (). MNC;
STR + = "imsi MCC (mobile country code):" + String. valueof (MCC) + "";
STR + = "imsi MNC (mobile network code):" + String. valueof (MNC) + "";
Result = STR;
Return result;
} In the above Code, first call the system's getsystemservice (context. the telephony_service method obtains a telephonymanager object TM, calls its method getdeviceid () to obtain DeviceID information, and CALLS getdevicesoftware version () to obtain the software version information of the device.
1.2.3 view hardware information
1.2.3.1 obtain CPU Information
You can obtain CPU information from/proc/cpuinfo on the mobile phone device, call cmdeexecute to execute the cat command of the system, and obtain the content of/proc/cpuinfo, which displays the CPU information, the implementation code is as follows:
Java code:
In the above Code, first call the system's getsystemservice (context. the telephony_service method obtains a telephonymanager object TM, calls its method getdeviceid () to obtain DeviceID information, and CALLS getdevicesoftware version () to obtain the software version information of the device.
1.2.3 view hardware information
1.2.3.1 obtain CPU Information
You can obtain CPU information from/proc/cpuinfo on the mobile phone device, call cmdeexecute to execute the cat command of the system, and obtain the content of/proc/cpuinfo, which displays the CPU information, the implementation code is as follows:
Java code:
Public static string fetch_cpu_info (){
String result = NULL;
Cmdexecute cmdexe = new cmdexecute ();
Try {
String [] ARGs = {"/system/bin/cat", "/proc/cpuinfo "};
Result = cmdexe. Run (ARGs, "/system/bin /");
Log. I ("result", "result =" + result );
} Catch (ioexception ex ){
Ex. printstacktrace ();
}
Return result;
}
The above Code uses cmdexecute to call the "/system/bin/cat" command in the system to view the content in "/proc/cpuinfo" to obtain CPU information.