android获取手机基本信息
来源:互联网 发布:java培训课程哪家好 编辑:程序博客网 时间:2024/05/29 16:37
- /**
- * 获取android当前可用内存大小
- */
- private String getAvailMemory() {// 获取android当前可用内存大小
- ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
- MemoryInfo mi = new MemoryInfo();
- am.getMemoryInfo(mi);
- //mi.availMem; 当前系统的可用内存
- 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();// 读取meminfo第一行,系统总内存大小
- arrayOfString = str2.split("\\s+");
- for (String num : arrayOfString) {
- Log.i(str2, num + "\t");
- }
- initial_memory = Integer.valueOf(arrayOfString[1]).intValue() * 1024;// 获得系统总内存,单位是KB,乘以1024转换为Byte
- localBufferedReader.close();
- } catch (IOException e) {
- }
- return Formatter.formatFileSize(getBaseContext(), initial_memory);// Byte转换为KB或者MB,内存大小规格化
- }
- /**
- * 获得手机屏幕宽高
- * @return
- */
- public String getHeightAndWidth(){
- int width=getWindowManager().getDefaultDisplay().getWidth();
- int heigth=getWindowManager().getDefaultDisplay().getHeight();
- String str=width+""+heigth+"";
- return str;
- }
- /**
- * 获取IMEI号,IESI号,手机型号
- */
- 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);
- }
- /**
- * .获取手机MAC地址
- * 只有手机开启wifi才能获取到mac地址
- */
- 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;
- }
- /**
- * 手机CPU信息
- */
- private String[] getCpuInfo() {
- String str1 = "/proc/cpuinfo";
- String str2 = "";
- String[] cpuInfo = {"", ""}; //1-cpu型号 //2-cpu频率
- 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" />
0 0
- 获取android手机基本信息
- android获取手机基本信息
- 获取android手机基本信息
- 获取android手机基本信息
- android获取手机基本信息
- Android获取手机的基本信息
- Android开发(42) 获取android手机基本信息
- Android 获取手机的一些基本信息
- Android 获取手机的一些基本信息类
- Android 获取手机基本信息,版本号,制造商,
- 获取手机基本信息
- android Build手机基本信息
- 安卓学习笔记---【Android】获取手机的基本信息
- Android中获取手机联系人的基本信息的实现
- Android获取系统基本信息
- 获取Android设备基本信息
- Android:获取应用基本信息
- 获取手机基本信息的工具类
- C++11 标准新特性:Defaulted 和 Deleted 函数
- 球谐函数
- 小胖说事45-----iOS hitTest:withEvent:方法流程
- java.sql.SQLException: Access denied for user 'root'@'localhost' (using password:YES)错误
- 用分部积分推导梯形数值积分公式
- android获取手机基本信息
- 【Xcode】【iOS-pod】The sandbox is not sync with the Podfile.lock
- ccpc Ancient Go(dfs求连通块周围'.'的数目)
- 小胖说事46-----iOS 控制台报错:No location, value may have been optimized out
- html 调用客户端exe并写入文本文件
- iOS9 新特性联系人Contact FrameWork---OC版
- U3D 三种实现截屏保存精彩瞬间方式
- iOS 保存和获取本地图片的封装函数
- 链表逆置--递归