Get basic information about Android phones

Source: Internet
Author: User

1 /** 2 * Get Android currently available memory size3  */  4  PrivateString Getavailmemory () {//get the current available memory size for Android5         6Activitymanager am =(Activitymanager) Getsystemservice (Context.activity_service); 7Memoryinfo mi =NewMemoryinfo (); 8 Am.getmemoryinfo (MI); 9         //Mi.availmem; available memory for the current systemTen      One         returnFormatter.formatfilesize (Getbasecontext (), MI.AVAILMEM);//normalize the acquired memory size A     }     -    - /**  the * Get total system memory -  */   - PrivateString gettotalmemory () { -String str1 = "/proc/meminfo";//system memory information file + String str2;  - string[] arrayofstring;  +     LongInitial_memory = 0;  A    at     Try {   -FileReader Localfilereader =NewFileReader (STR1);  -BufferedReader Localbufferedreader =NewBufferedReader ( -Localfilereader, 8192);  -STR2 = Localbufferedreader.readline ();//read Meminfo First line, total system memory size -    inarrayofstring = Str2.split ("\\s+");  -      for(String num:arrayofstring) { toLOG.I (str2, num + "\ T");  +     }   -    theInitial_memory = integer.valueof (Arrayofstring[1]). Intvalue () * 1024;//gets the total system memory, in kilobytes, multiplied by 1024 to byte * Localbufferedreader.close ();  $   Panax Notoginseng}Catch(IOException e) { -     }   the     returnFormatter.formatfilesize (Getbasecontext (), initial_memory);//byte converted to KB or MB, memory size normalized +     }   A    the /**  + * Get phone screen width high -  * @return  $  */   $  PublicString getheightandwidth () { -     intWidth=Getwindowmanager (). Getdefaultdisplay (). GetWidth ();  -     intHeigth=Getwindowmanager (). Getdefaultdisplay (). GetHeight ();  theString str=width+ "" +heigth+ "";  -     returnstr; Wuyi }   the /**  - * Get IMEI number, Iesi number, phone model Wu  */   - Private voidGetInfo () { AboutTelephonymanager mTm = (Telephonymanager) This. Getsystemservice (Telephony_service);  $String IMEI =Mtm.getdeviceid ();  -String IMSI =Mtm.getsubscriberid ();  -String mtype = Android.os.Build.MODEL;//Phone Model -String mtyb= Android.os.Build.BRAND;//Mobile Brand AString Numer = Mtm.getline1number ();//mobile phone number, some can get, some can't get +LOG.I ("text", "Phone IMEI number:" +imei+ "mobile phone Iesi number:" +imsi+ "phone Model:" +mtype+ "mobile phone Brand:" +mtyb+ "mobile phone number" +Numer);  the    }   - /**  $ *. Get phone MAC address the * Only the phone turns on WiFi to get the MAC address the  */   the PrivateString getmacaddress () { theString result = "";  -Wifimanager Wifimanager =(Wifimanager) Getsystemservice (Context.wifi_service);  inWifiinfo Wifiinfo =Wifimanager.getconnectioninfo ();  theresult =wifiinfo.getmacaddress ();  theLOG.I ("Text", "Mobile Macadd:" +result);  About        returnresult;  the    }   the /**  the * Mobile CPU Information +  */   - Privatestring[] Getcpuinfo () { theString str1 = "/proc/cpuinfo"; BayiString str2 = "";  theString[] CpuInfo = {"", ""};//1-CPU Model//2-CPU Frequency the string[] arrayofstring;  -        Try {   -FileReader FR =NewFileReader (STR1);  theBufferedReader Localbufferedreader =NewBufferedReader (FR, 8192);  theSTR2 =Localbufferedreader.readline ();  thearrayofstring = Str2.split ("\\s+");  the             for(inti = 2; i < arrayofstring.length; i++) {   -Cpuinfo[0] = cpuinfo[0] + arrayofstring[i] + "";  the            }   theSTR2 =Localbufferedreader.readline ();  thearrayofstring = Str2.split ("\\s+"); 94CPUINFO[1] + = arrayofstring[2];  the Localbufferedreader.close ();  the}Catch(IOException e) { the        }  98LOG.I ("text", "Cpuinfo:" + cpuinfo[0] + "" + cpuinfo[1]);  About        returnCpuInfo;  -}
1 <!--         Get MAC Address permissions--  2     <uses-permission android:name= " Android.permission.ACCESS_WIFI_STATE "/>    3 <!--     Get Mobile Information right--  4     <uses-permission android:name= "Android.permission.READ_PHONE_STATE"/>  

Get basic information about Android phones

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.