<em id="0a85b"><option id="0a85b"></option></em>

<abbr id="0a85b"></abbr>

      <nobr id="0a85b"></nobr>
        <tr id="0a85b"></tr>
        9久久伊人精品综合,亚洲一区精品视频在线,成 人免费va视频,国产一区二区三区黄网,99国产精品永久免费视频,亚洲毛片多多影院,精品久久久无码人妻中文字幕,无码国产欧美一区二区三区不卡
        學習啦 > 學習電腦 > 電腦硬件知識 > CPU知識 > Android怎么獲取cpu信息

        Android怎么獲取cpu信息

        時間: 沈迪豪908 分享

        Android怎么獲取cpu信息

          學習Android開發(fā)的同學們你們知道怎么獲取cpu信息嗎?下面由學習啦小編教大家怎么Android怎么獲取cpu信息。

          Android獲取cpu信息的方法

          1、CPU頻率,CPU信息:/proc/cpuinfo和/proc/stat

          通過讀取文件/proc/cpuinfo系統(tǒng)CPU的類型等多種信息。

          讀取/proc/stat 所有CPU活動的信息來計算CPU使用率

          下面我們就來講講如何通過代碼來獲取CPU頻率:

          package com.orange.cpu;

          import java.io.BufferedReader;

          import java.io.FileNotFoundException;

          import java.io.FileReader;

          import java.io.IOException;

          import java.io.InputStream;

          public class CpuManager {

          // 獲取CPU最大頻率(單位KHZ)

          // "/system/bin/cat" 命令行

          // "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq" 存儲最大頻率的文件的路徑

          public static String getMaxCpuFreq() {

          String result = "";

          ProcessBuilder cmd;

          try {

          String[] args = { "/system/bin/cat",

          "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq" };

          cmd = new ProcessBuilder(args);

          Process process = cmd.start();

          InputStream in = process.getInputStream();

          byte[] re = new byte[24];

          while (in.read(re) != -1) {

          result = result + new String(re);

          }

          in.close();

          } catch (IOException ex) {

          ex.printStackTrace();

          result = "N/A";

          }

          return result.trim();

          }

          // 獲取CPU最小頻率(單位KHZ)

          public static String getMinCpuFreq() {

          String result = "";

          ProcessBuilder cmd;

          try {

          String[] args = { "/system/bin/cat",

          "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq" };

          cmd = new ProcessBuilder(args);

          Process process = cmd.start();

          InputStream in = process.getInputStream();

          byte[] re = new byte[24];

          while (in.read(re) != -1) {

          result = result + new String(re);

          }

          in.close();

          } catch (IOException ex) {

          ex.printStackTrace();

          result = "N/A";

          }

          return result.trim();

          }

          // 實時獲取CPU當前頻率(單位KHZ)

          public static String getCurCpuFreq() {

          String result = "N/A";

          try {

          FileReader fr = new FileReader(

          "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq");

          BufferedReader br = new BufferedReader(fr);

          String text = br.readLine();

          result = text.trim();

          } catch (FileNotFoundException e) {

          e.printStackTrace();

          } catch (IOException e) {

          e.printStackTrace();

          }

          return result;

          }

          // 獲取CPU名字

          public static String getCpuName() {

          try {

          FileReader fr = new FileReader("/proc/cpuinfo");

          BufferedReader br = new BufferedReader(fr);

          String text = br.readLine();

          String[] array = text.split(":\s+", 2);

          for (int i = 0; i < array.length; i++) {

          }

          return array[1];

          } catch (FileNotFoundException e) {

          e.printStackTrace();

          } catch (IOException e) {

          e.printStackTrace();

          }

          return null;

          }

          }

          2、內(nèi)存:/proc/meminfo

          public void getTotalMemory() {

          String str1 = "/proc/meminfo";

          String str2="";

          try {

          FileReader fr = new FileReader(str1);

          BufferedReader localBufferedReader = new BufferedReader(fr, 8192);

          while ((str2 = localBufferedReader.readLine()) != null) {

          Log.i(TAG, "---" + str2);

          }

          } catch (IOException e) {

          }

          }

          3、Rom大小 www.2cto.com

          public long[] getRomMemroy() {

          long[] romInfo = new long[2];

          //Total rom memory

          romInfo[0] = getTotalInternalMemorySize();

          //Available rom memory

          File path = Environment.getDataDirectory();

          StatFs stat = new StatFs(path.getPath());

          long blockSize = stat.getBlockSize();

          long availableBlocks = stat.getAvailableBlocks();

          romInfo[1] = blockSize * availableBlocks;

          getVersion();

          return romInfo;

          }

          public long getTotalInternalMemorySize() {

          File path = Environment.getDataDirectory();

          StatFs stat = new StatFs(path.getPath());

          long blockSize = stat.getBlockSize();

          long totalBlocks = stat.getBlockCount();

          return totalBlocks * blockSize;

          }

          4、sdCard大小

          public long[] getSDCardMemory() {

          long[] sdCardInfo=new long[2];

          String state = Environment.getExternalStorageState();

          if (Environment.MEDIA_MOUNTED.equals(state)) {

          File sdcardDir = Environment.getExternalStorageDirectory();

          StatFs sf = new StatFs(sdcardDir.getPath());

          long bSize = sf.getBlockSize();

          long bCount = sf.getBlockCount();

          long availBlocks = sf.getAvailableBlocks();

          sdCardInfo[0] = bSize * bCount;//總大小

          sdCardInfo[1] = bSize * availBlocks;//可用大小

          }

          return sdCardInfo;

          }

          5、電池電量

          private BroadcastReceiver batteryReceiver=new BroadcastReceiver(){

          @Override

          public void onReceive(Context context, Intent intent) {

          int level = intent.getIntExtra("level", 0);

          // level加%就是當前電量了

          }

          };

          registerReceiver(batteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

          6、系統(tǒng)的版本信息

          ?

          public String[] getVersion(){

          String[] version={"null","null","null","null"};

          String str1 = "/proc/version";

          String str2;

          String[] arrayOfString;

          try {

          FileReader localFileReader = new FileReader(str1);

          BufferedReader localBufferedReader = new BufferedReader(

          localFileReader, 8192);

          str2 = localBufferedReader.readLine();

          arrayOfString = str2.split("\s+");

          version[0]=arrayOfString[2];//KernelVersion

          localBufferedReader.close();

          } catch (IOException e) {

          }

          version[1] = Build.VERSION.RELEASE;// firmware version

          version[2]=Build.MODEL;//model

          version[3]=Build.DISPLAY;//system version

          return version;

          }

          7、mac地址和開機時間

          ?

          public String[] getOtherInfo(){

          String[] other={"null","null"};

          WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);

          WifiInfo wifiInfo = wifiManager.getConnectionInfo();

          if(wifiInfo.getMacAddress()!=null){

          other[0]=wifiInfo.getMacAddress();

          } else {

          other[0] = "Fail";

          }

          other[1] = getTimes();

          return other;

        Android怎么獲取cpu信息相關(guān)文章:

        1.如何獲取CPU序列號

        2.Linux怎么獲取CPU數(shù)量

        3.Android Build類如何獲取手機硬件信息

        4.android怎么獲取硬件信息

        5.怎么通過代碼獲取手機的相關(guān)硬件信息

        6.如何查看手機CPU

          }

          private String getTimes() {

          long ut = SystemClock.elapsedRealtime() / 1000;

          if (ut == 0) {

          ut = 1;

          }

          int m = (int) ((ut / 60) % 60);

          int h = (int) ((ut / 3600));

          return h + " " + mContext.getString(R.string.info_times_hour) + m + " "

          + mContext.getString(R.string.info_times_minute);

          }

        2018872 主站蜘蛛池模板: 自拍偷自拍亚洲精品熟妇人| 无卡无码无免费毛片| 国产一区二区三区在线观看免费| 亚洲精品第一区二区三区| 久久国产免费直播| 91人妻熟妇在线视频| 操操操综合网| 无码国产精品一区二区免费网曝 | 亚洲无码久久久久| 九九热在线视频中文字幕| 99国产精品久久久久久久成人热| 亚洲国产精品老熟女乱码| 中文字幕在线观看一区二区| 国产午夜在线观看视频播放| 欧美www在线观看| 在线观看欧美精品二区| 一区二区中文字幕久久| 中文无码av一区二区三区 | 日韩精品无码区免费专区 | 亚洲男人在线天堂| 又大又长粗又爽又黄少妇毛片| 中文字幕日韩国产精品| 国产91在线|中文| 人妻系列无码专区无码中出| 国产精品一区二区性色av| 乱码精品一区二区三区| 国产热A欧美热A在线视频| 色哟哟国产成人精品| 国产精品伊人久久综合网| 午夜免费无码福利视频麻豆| 熟妇人妻av中文字幕老熟妇| 国产一级av一区二区在线| 精品亚洲国产成人| 在线一区二区中文字幕| 免费国产一级 片内射老| 亚洲精品中文字幕日本| 99久久精品国产熟女拳交| 亚洲人成网站77777在线观看| 中文字幕不卡在线播放| 人人妻人人揉人人模人人模| 一级女性全黄久久生活片|