Package com. liu. phone. help; import java. io. bufferedReader; import java. io. fileReader; import java. io. IOException; import java. util. list; import android. app. activity; import android. app. activityManager; import android. app. activityManager. memoryInfo; import android. content. context; import android. content. pm. applicationInfo; import android. content. pm. packageInfo; import android.net. wifi. wifiInfo; import android.net. wifi. wifiManager; import android. telephony. telephonyManager; import android. text. format. formatter; import android. util. displayMetrics; import android. util. log;/*** mobile phone basic information class * @ author Administrator **/public class PhoneInfo {public static final String TAG = "PhoneInfo "; /*** get all apps on the mobile phone * @ return */public static String getAllApp (Context context) {String result = ""; List <PackageInfo> packages = context. getPackageManager (). getInstalledPackages (0); for (PackageInfo I: packages) {if (I. applicationInfo. flags & ApplicationInfo. FLAG_SYSTEM) = 0) {result + = I. applicationInfo. loadLabel (context. getPackageManager ()). toString () + "," ;}} return result. substring (0, result. length ()-1);}/*** get available mobile phone memory * @ param context * @ return */public static String getAvailMemory (Context context) {// get the current available memory size of android ActivityManager am = (ActivityManager) context. getSystemService (Context. ACTIVITY_SERVICE); MemoryInfo mi = new MemoryInfo (); am. getMemoryInfo (mi); return Formatter. formatFileSize (context, mi. availMem); // normalize the obtained memory size}/*** obtain the phone's memory information * @ return */public static String [] getTotalMemory (Context context) {String [] result = {"", ""}; // 1-total 2-avail ActivityManager am = (ActivityManager) context. getSystemService (Context. ACTIVITY_SERVICE); MemoryInfo mi = new MemoryInfo (); am. getMemoryInfo (mi); long mTotalMem = 0; long mAvailMem = mi. availMem; String str1 = "/proc/meminfo"; String str2; String [] character; try {FileReader localFileReader = new FileReader (str1); BufferedReader localBufferedReader = new BufferedReader (localFileReader, 8192); str2 = localBufferedReader. readLine (); arrayOfString = str2.split ("\ s +"); mTotalMem = Integer. valueOf (arrayOfString [1]). intValue () * 1024; localBufferedReader. close ();} catch (IOException e) {e. printStackTrace ();} result [0] = Formatter. formatFileSize (context, mTotalMem); result [1] = Formatter. formatFileSize (context, mAvailMem); Log. I (TAG, "meminfo total:" + result [0] + "used:" + result [1]); return result ;} /*** get mobile phone CPU information * @ return */public static String [] getCpuInfo () {String str1 = "/proc/cpuinfo"; String str2 = ""; string [] cpuInfo = {"", ""}; // 1-cpu model // 2-cpu frequency 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) {} Log. I (TAG, "cpuinfo:" + cpuInfo [0] + "" + cpuInfo [1]); return cpuInfo ;} /*** get the mac address of the mobile phone * @ return */public static String getMacAddress (Context context) {String result; WifiManager wifiManager = (WifiManager) context. getSystemService (Context. WIFI_SERVICE); WifiInfo wifiInfo = wifiManager. getConnectionInfo (); result = wifiInfo. getMacAddress (); return result;}/*** get the IMEI, IMSI, mobile phone model, mobile phone number */public static String getInfo (Context context) of the mobile phone) {TelephonyManager mTm = (TelephonyManager) context. getSystemService (Context. TELEPHONY_SERVICE); StringBuilder sb = new StringBuilder (); String imei = mTm. getDeviceId (); sb. append (imei ). append (","); String imsi = mTm. getSubscriberId (); sb. append (imsi ). append (","); String mtype = android. OS. build. MODEL; // mobile phone MODEL sb. append (mtype ). append (","); String numer = mTm. getLine1Number (); // mobile phone number. Some are available and some cannot obtain sb. append (numer ). append (","); return sb. toString ();}/*** get the width and height of the mobile phone */public static String getWeithAndHeight (Activity activity) {// This method cannot be used in service, displayMetrics dm = new DisplayMetrics (); activity. getWindowManager (). getdefadisplay display (). getMetrics (dm); StringBuilder sb = new StringBuilder (); String width = String. valueOf (dm. widthPixels); // width sb. append (width ). append (","); String height = String. valueOf (dm. heightPixels); // high sb. append (height ). append (","); return sb. toString (); // the height and width can also be obtained in the service. // WindowManager mWindowManager = (WindowManager) context. getSystemService (Context. WINDOW_SERVICE); // width = mWindowManager. getdefadisplay display (). getWidth (); // height = mWindowManager. getdefadisplay display (). getHeight ();}}