1:通过Build类和System类来获取系统的信息,具体代码如下所示:
private String getDeviceInfo() {
StringBuffer sb = new StringBuffer();
sb.append("主板:" + Build.BOARD);
sb.append("\n系统启动程序版本号:" + Build.BOOTLOADER);
sb.append("\n系统定制商:" + Build.BRAND);
sb.append("\ncpu指令集:" + Build.CPU_ABI);
sb.append("\ncpu指令集2" + Build.CPU_ABI2);
sb.append("\n设置参数:" + Build.DEVICE);
sb.append("\n显示屏参数:" + Build.DISPLAY);
sb.append("\n无线电固件版本:" + Build.getRadioVersion());
sb.append("\n硬件识别码:" + Build.FINGERPRINT);
sb.append("\n硬件名称:" + Build.HARDWARE);
sb.append("\nHOST:" + Build.HOST);
sb.append("\n修订版本列表:" + Build.ID);
sb.append("\n硬件制造商:" + Build.MANUFACTURER);
sb.append("\n版本:" + Build.MODEL);
sb.append("\n硬件序列号:" + Build.SERIAL);
sb.append("\n手机制造商:" + Build.PRODUCT);
sb.append("\n描述Build的标签:" + Build.TAGS);
sb.append("\nTIME:" + Build.TIME);
sb.append("\nbuilder类型:" + Build.TYPE);
sb.append("\nUSER:" + Build.USER);
sb.append("\n路径分隔符:" + System.getProperty("path.separator"));
sb.append("\n行分隔符:" + System.getProperty("line.separator"));
sb.append("\n文件分隔符:" + System.getProperty("file.separator"));
sb.append("\njava版本:" + System.getProperty("java.version"));
return sb.toString();
}
输出结果为:
主板:KIW-AL10
系统启动程序版本号:unknown
系统定制商:HONOR
cpu指令集:arm64-v8a
cpu指令集2
设置参数:HNKIW-Q
显示屏参数:KIW-AL10C92B443
无线电固件版本:20234,20234
硬件识别码:HONOR/KIW-AL10/HNKIW-Q:6.0.1/HONORKIW-AL10/C92B443:user/release-keys
硬件名称:qcom
HOST:localhost#1
修订版本列表:HONORKIW-AL10
硬件制造商:HUAWEI
版本:KIW-AL10
硬件序列号:QMS0216608002654
手机制造商:KIW-AL10
描述Build的标签:release-keys
TIME:1513118432000
builder类型:user
USER:android
路径分隔符::
行分隔符:
文件分隔符:/
java版本:0
2:PackageManager
常用的方法如下所示:
示例代码如下:
PackageManager packageManager=getPackageManager(); List<ApplicationInfo>list=packageManager.getInstalledApplications(PackageManager.COMPONENT_ENABLED_STATE_DEFAULT);
for (int i = 0; i < list.size(); i++) {
Log.d("CeShi", list.get(i).toString()+"\n");//输出手机上安装的app的包信息
}
3:ActivityManager
示例代码如下:
ActivityManager activityManager= (ActivityManager) getSystemService(ACTIVITY_SERVICE); List<ActivityManager.RunningAppProcessInfo>list=activityManager.getRunningAppProcesses();
for (int i = 0; i < list.size(); i++) {
Debug.MemoryInfo[] memoryInfos=activityManager.getProcessMemoryInfo(new int[]{list.get(i).pid});
Log.d("CeShi", list.get(i).processName + "," +memoryInfos[i].getTotalPss());//只输出了当前app进程,输出结果为:com.example.liang.arlvyou,12877
}