获取android手机基本信息
2025-03-01 15:58:47 来源: 阅读:
- private String getAvailMemory() {
-
- ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
- MemoryInfo mi = new MemoryInfo();
- am.getMemoryInfo(mi);
-
-
- return Formatter.formatFileSize(getBaseContext(), mi.availMem);
- }
-
- private String getTotalMemory() {
- String str1 = "/proc/meminfo";
- String str2;
- String[] arrayOfString;
- long initial_memory = 0;
-
- try {
- FileReader localFileReader = new FileReader(str1);
- BufferedReader localBufferedReader = new BufferedReader(
- localFileReader, 8192);
- str2 = localBufferedReader.readLine();
-
- arrayOfString = str2.split("\\s+");
- for (String num : arrayOfString) {
- Log.i(str2, num + "\t");
- }
-
- initial_memory = Integer.valueOf(arrayOfString[1]).intValue() * 1024;
- localBufferedReader.close();
-
- } catch (IOException e) {
- }
- return Formatter.formatFileSize(getBaseContext(), initial_memory);
- }
-
- public String getHeightAndWidth(){
- int width=getWindowManager().getDefaultDisplay().getWidth();
- int heigth=getWindowManager().getDefaultDisplay().getHeight();
- String str=width+""+heigth+"";
- return str;
- }
- private void getInfo() {
- TelephonyManager mTm = (TelephonyManager)this.getSystemService(TELEPHONY_SERVICE);
- String imei = mTm.getDeviceId();
- String imsi = mTm.getSubscriberId();
- String mtype = android.os.Build.MODEL;
- String mtyb= android.os.Build.BRAND;
- String numer = mTm.getLine1Number();
- Log.i("text", "手机IMEI号:"+imei+"手机IESI号:"+imsi+"手机型号:"+mtype+"手机品牌:"+mtyb+"手机号码"+numer);
- }
- private String getMacAddress(){
- String result = "";
- WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
- WifiInfo wifiInfo = wifiManager.getConnectionInfo();
- result = wifiInfo.getMacAddress();
- Log.i("text", "手机macAdd:" + result);
- return result;
- }
- private 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) {
- }
- Log.i("text", "cpuinfo:" + cpuInfo[0] + " " + cpuInfo[1]);
- return cpuInfo;
- }
- <!-- 获取mac地址权限 -->
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
- <!-- 获取手机信息权限 -->
- <uses-permission android:name="android.permission.READ_PHONE_STATE" />