Come and have a look at the android games!
1. Obtain the app information installed on your mobile phone (excluding the app information that comes with the system ):
Java code:
1 private String getAllApp() {
2 String result = "";
3 List<PackageInfo> packages = getPackageManager().getInstalledPackages(0);
4 for (PackageInfo i : packages) {
5 if ((i.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
6 result += i.applicationInfo.loadLabel(getPackageManager()).toString() + ",";
7 }
8 }
9 return result.substring(0, result.length() - 1);
10 }
Return the app1, app2, app3,..., and Appn separated by "," in the form of a string. Of course, you can also get the package name, icon, and so on.
2. Get the available memory and total memory of the mobile phone:
Java code:
1 private String[] getTotalMemory() {
2 String[] result = {"",""}; //1-total 2-avail
3 ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
4 mActivityManager.getMemoryInfo(mi);
5 long mTotalMem = 0;
6 long mAvailMem = mi.availMem;
7 String str1 = "/proc/meminfo";
8 String str2;
9 String[] arrayOfString;
10 try {
11 FileReader localFileReader = new FileReader(str1);
12 BufferedReader localBufferedReader = new BufferedReader(localFileReader, 8192);
13 str2 = localBufferedReader.readLine();
14 arrayOfString = str2.split("\\s+");
15 mTotalMem = Integer.valueOf(arrayOfString[1]).intValue() * 1024;
16 localBufferedReader.close();
17 } catch (IOException e) {
18 e.printStackTrace();
19 }
20 result[0] = Formatter.formatFileSize(this, mTotalMem);
21 result[1] = Formatter.formatFileSize(this, mAvailMem);
22 Log.i(TAG, "meminfo total:" + result[0] + " used:" + result[1]);
23 return result;
24 }
The memory information of the mobile phone is mainly in the/proc/meminfo file. The first line is the total memory, and the remaining memory can be obtained through activitymanager. memoryinfo.
3. Mobile phone CPU Information
Java code:
1 private string [] getcpuinfo (){
2 string str1 = "/proc/cpuinfo ";
3 string str2 = "";
4 string [] cpuinfo = {"", ""}; // 1-cpu model // 2-cpu frequency
5 string [] arrayofstring;
6 try {
7 filereader Fr = new filereader (str1 );
8 bufferedreader localbufferedreader = new bufferedreader (FR, 8192 );
9 str2 = localbufferedreader. Readline ();
10 arrayofstring = str2.split ("\ s + ");
11 For (INT I = 2; I <arrayofstring. length; I ++ ){
12 cpuinfo [0] = cpuinfo [0] + arrayofstring [I] + "";
13}
14 str2 = localbufferedreader. Readline ();
15 arrayofstring = str2.split ("\ s + ");
16 cpuinfo [1] + = arrayofstring [2];
17 localbufferedreader. Close ();
18} catch (ioexception e ){
19}
20 log. I (TAG, "cpuinfo:" + cpuinfo [0] + "" + cpuinfo [1]);
21 return cpuinfo;
22}
Similar to the memory information, the CPU information can be obtained by reading the/proc/cpuinfo file, where the first act is the CPU model and the second act is the CPU frequency.
4. Obtain the MAC address of the mobile phone:
Java code:
1 private String getMacAddress(){
2 String result = "";
3 WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
4 WifiInfo wifiInfo = wifiManager.getConnectionInfo();
5 result = wifiInfo.getMacAddress();
6 Log.i(TAG, "macAdd:" + result);
7 return result;
8 }
The MAC address is relatively easy and can be obtained directly through wifimanager.
4. IMEI, iesi, and mobile phone model:
Java code:
1 private void getinfo (){
2 telephonymanager MTM = (telephonymanager) getsystemservice (telephony_service );
3 string IMEI = MTM. getdeviceid ();
4 string imsi = MTM. getsubscriberid ();
5 string mtype = Android. OS. Build. Model; // Mobile Phone Model
6 string numer = MTM. getline1number (); // mobile phone number, which is available or unavailable
7}
5. Get the screen height of the mobile phone:
Java code:
1 private void getweithandheight (){
2 // This method cannot be used in the service,
3 displaymetrics dm = new displaymetrics ();
4 getwindowmanager (). getdefaultdisplay (). getmetrics (DM );
5 string width = DM. widthpixels; // width
6 string height = DM. heightpixels; // high
7
8 // the height and width can also be obtained in the service
9 windowmanager mwindowmanager = (windowmanager) getsystemservice (context. window_service );
10 width = mwindowmanager. getdefaultdisplay (). getwidth ();
11 Height = mwindowmanager. getdefaultdisplay (). getheight ();
12}