- /**
- * Get mobile phone information
- */
- Public void getphoneinfo ()
- {
- Telephonymanager TM = (telephonymanager) This. getsystemservice (telephony_service );
- String mtyb = Android. OS. Build. Brand; // mobile phone brand
- String mtype = Android. OS. Build. Model; // Mobile Phone Model
- String IMEI = TM. getdeviceid ();
- String imsi = TM. getsubscriberid ();
- String numer = TM. getline1number (); // mobile phone number
- String servicename = TM. getsimoperatorname (); // Carrier
- Tvphoneinfo. settext ("brand:" + mtyb + "\ n" + "model:" + mtype + "\ n" + "version: Android" + android. OS. build. version. release + "\ n" + "IMEI:" + IMEI
- + "\ N" + "imsi:" + imsi + "\ n" + "mobile phone number:" + numer + "\ n" + "carrier: "+ servicename +" \ n ");
- }
[Java]
View plaincopyprint?
- /**
- * Get the phone memory size
- *
- * @ Return
- */
- Private string gettotalmemory ()
- {
- String str1 = "/proc/meminfo"; // system memory information file
- String str2;
- String [] arrayofstring;
- Long initial_memory = 0;
- Try
- {
- Filereader localfilereader = new filereader (str1 );
- Bufferedreader localbufferedreader = new bufferedreader (localfilereader, 8192 );
- Str2 = localbufferedreader. Readline (); // read the first line of meminfo, total system memory size
- Arrayofstring = str2.split ("\ s + ");
- For (string num: arrayofstring)
- {
- Log. I (str2, num + "\ t ");
- }
- Initial_memory = integer. valueof (arrayofstring [1]). intvalue () * 1024; // obtain the total system memory, measured in KB, multiplied by 1024 to byte
- Localbufferedreader. Close ();
- }
- Catch (ioexception E)
- {
- }
- Return formatter. formatfilesize (getbasecontext (), initial_memory); // convert byte to kb or MB, and normalize the memory size.
- }
[Java]
View plaincopyprint?
- /**
- * Get the current available memory size
- *
- * @ Return
- */
- Private string getavailmemory ()
- {
- Activitymanager AM = (activitymanager) getsystemservice (context. activity_service );
- Memoryinfo MI = new memoryinfo ();
- Am. getmemoryinfo (MI );
- Return formatter. formatfilesize (getbasecontext (), mi. availmem );
- }
[Java]
View plaincopyprint?
- /**
- * Obtain the CPU information of the mobile phone.
- *
- * @ Return
- */
- Public String [] getcpuinfo ()
- {
- String str1 = "/proc/cpuinfo ";
- String str2 = "";
- String [] cpuinfo = {"",""};
- String [] arrayofstring;
- Try
- {
- Filereader Fr = new filereader (str1 );
- Bufferedreader localbufferedreader = new bufferedreader (FR, 8192 );
- Str2 = localbufferedreader. Readline ();
- Arrayofstring = str2.split ("\ s + ");
- For (INT I = 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)
- {
- }
- Tvhardwareinfo. append ("CPU model" + cpuinfo [0] + "\ n" + "CPU frequency:" + cpuinfo [1] + "\ n ");
- Return cpuinfo;
- }
[Java]
View plaincopyprint?
- /**
- * Obtain the number of CPU Cores
- *
- * @ Return
- */
- Private int getnumcores ()
- {
- // Private class to display only CPU devices in the Directory Listing
- Class cpufilter implements filefilter
- {
- @ Override
- Public Boolean accept (File pathname)
- {
- // Check if filename is "CPU", followed by a single digit number
- If (pattern. Matches ("CPU [0-9]", pathname. getname ()))
- {
- Return true;
- }
- Return false;
- }
- }
- Try
- {
- // Get directory containing CPU info
- File dir = new file ("/sys/devices/system/CPU /");
- // Filter to only list the devices we care about
- File [] files = dir. listfiles (New cpufilter ());
- // Return the number of cores (virtual CPU devices)
- Return files. length;
- }
- Catch (exception E)
- {
- E. printstacktrace ();
- // Default to return 1 core
- Return 1;
- }
- }
Source: http://blog.csdn.net/vestigge/article/details/8691894