加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

android获取手机信息大全

发布时间:2020-12-14 23:26:28 所属栏目:Java 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 IMEI号,IESI号,手机型号: [java] ? view plain copy print ? private?void?getInfo()?{???? ?????????????TelephonyManager?mTm?=?(TelephonyManag

以下代码由PHP站长网 52php.cn收集自互联网

现在PHP站长网小编把它分享给大家,仅供参考

IMEI号,IESI号,手机型号:

[java]? view plain copy print ?
  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;?//?手机型号????
  6. ?????????????String?numer?=?mTm.getLine1Number();?//?手机号码,有的可得,有的不可得????
  7. ?????????}??
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    TextView textView = (TextView) findViewById(R.id.text);
    textView.setText("Product Model: " + android.os.Build.MODEL + ","
                + android.os.Build.VERSION.SDK + ","
                + android.os.Build.VERSION.RELEASE);
}

String MODEL The end-user-visible name for the end product.
String SDK This constant is deprecated. Use?SDK_INT?to easily get this as an integer.
String RELEASE The user-visible version string.

String BOARD The name of the underlying board,like "goldfish".
String BOOTLOADER The system bootloader version number.
String BRAND The brand (e.g.,carrier) the software is customized for,if any.
String CPU_ABI The name of the instruction set (CPU type + ABI convention) of native code.
String CPU_ABI2 The name of the second instruction set (CPU type + ABI convention) of native code.
String DEVICE The name of the industrial design.
String DISPLAY A build ID string meant for displaying to the user
String FINGERPRINT A string that uniquely identifies this build.
String HARDWARE The name of the hardware (from the kernel command line or /proc).
String HOST ?
String ID Either a changelist number,or a label like "M4-rc20".
String MANUFACTURER The manufacturer of the product/hardware.
String MODEL The end-user-visible name for the end product.
String PRODUCT The name of the overall product.
String RADIO The radio firmware version number.
String SERIAL A hardware serial number,if available.
String TAGS Comma-separated tags describing the build,like "unsigned,debug".
long TIME ?
String TYPE The type of build,like "user" or "eng".
String UNKNOWN Value used for when a build property is unknown.
String USER


获取手机屏幕高度:

[java]? view plain copy print ?
  1. private?void?getWeithAndHeight(){????
  2. ????????????//这种方式在service中无法使用,????
  3. ????????????DisplayMetrics?dm?=?new?DisplayMetrics();????
  4. ????????????getWindowManager().getDefaultDisplay().getMetrics(dm);????
  5. ????????????String?width?=?dm.widthPixels;??????????????//宽????
  6. ????????????String?height?=?dm.heightPixels;???????????//高????
  7. ?????????
  8. ????????????//在service中也能得到高和宽????
  9. ????????????WindowManager?mWindowManager?=?(WindowManager)?getSystemService(Context.WINDOW_SERVICE);????
  10. ????????????width?=?mWindowManager.getDefaultDisplay().getWidth();????
  11. ????????????height?=?mWindowManager.getDefaultDisplay().getHeight();????
  12. ????????}??


获取手机MAC地址:

[java]? view plain copy print ?
  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. ?????}??

手机CPU信息

[java]? view plain copy print ?
  1. private?String[]?getCpuInfo()?{????
  2. ?????????????String?str1?=?"/proc/cpuinfo";????
  3. ?????????????String?str2?=?"";????
  4. ?????????????String[]?cpuInfo?=?{"",?""};??//1-cpu型号??//2-cpu频率????
  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[]?=?cpuInfo[]?+?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[]?+?"?"?+?cpuInfo[1]);????
  21. ?????????????return?cpuInfo;????
  22. ?????????}??

获取手机可用内存和总内存:

[java]? view plain copy print ?
  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?=?;????
  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[]?=?Formatter.formatFileSize(this,?mTotalMem);????
  21. ????????????result[1]?=?Formatter.formatFileSize(this,?mAvailMem);????
  22. ????????????Log.i(TAG,?"meminfo?total:"?+?result[]?+?"?used:"?+?result[1]);????
  23. ????????????return?result;????
  24. ????????}??

获取手机安装的应用信息(排除系统自带):

[java]? view plain copy print ?
  1. private?String?getAllApp()?{????
  2. ?????????????String?result?=?"";????
  3. ?????????????List<PackageInfo>?packages?=?getPackageManager().getInstalledPackages();????
  4. ?????????????for?(PackageInfo?i?:?packages)?{????
  5. ?????????????????if?((i.applicationInfo.flags?&?ApplicationInfo.FLAG_SYSTEM)?==?)?{????
  6. ?????????????????????result?+=?i.applicationInfo.loadLabel(getPackageManager()).toString()?+?",";????
  7. ?????????????????}????
  8. ?????????????}????
  9. ?????????????return?result.substring(,?result.length()?-?1);????
  10. ?????}??

以上内容由PHP站长网【52php.cn】收集整理供大家参考研究

如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读