android獲取手機(jī)cpu并判斷是單核還是多核
更新時間:2013年02月21日 15:41:11 作者:
手機(jī)cpu是單核還是多核如何判斷,本例將會介紹android中獲取的方法,感興趣的你可不要錯過了哈
復(fù)制代碼 代碼如下:
/**
* Gets the number of cores available in this device, across all processors.
* Requires: Ability to peruse the filesystem at "/sys/devices/system/cpu"
* @return The number of cores, or 1 if failed to get result
*/
private int getNumCores() {
//Private Class to display only CPU devices in the directory listing
class CpuFilter implements FileFilter {
@Override
public boolean accept(File pathname) {
//Check if filename is "cpu", followed by a single digit number
if(Pattern.matches("cpu[0-9]", pathname.getName())) {
return true;
}
return false;
}
}
try {
//Get directory containing CPU info
File dir = new File("/sys/devices/system/cpu/");
//Filter to only list the devices we care about
File[] files = dir.listFiles(new CpuFilter());
//Return the number of cores (virtual CPU devices)
return files.length;
} catch(Exception e) {
//Default to return 1 core
return 1;
}
}
您可能感興趣的文章:
- 解決Android 高CPU占用率的問題
- Android、Flutter為不同的CPU架構(gòu)包打包APK(v7a、v8a、x86區(qū)別)
- Python獲取android設(shè)備cpu和內(nèi)存占用情況
- 淺析AndroidStudio3.0最新 Android Profiler分析器(cpu memory network 分析器)
- Android編程實現(xiàn)獲取系統(tǒng)內(nèi)存、CPU使用率及狀態(tài)欄高度的方法示例
- Android獲取設(shè)備CPU核數(shù)、時鐘頻率以及內(nèi)存大小的方法
- 解析Android獲取系統(tǒng)cpu信息,內(nèi)存,版本,電量等信息的方法詳解
- Android 輕松獲取CPU型號的方法
相關(guān)文章
Android判斷應(yīng)用程序退到后臺的方法(示例代碼)
判斷手機(jī)是否退到后臺,這是我們在Android開發(fā)中實現(xiàn)一些功能時,經(jīng)常會考慮的問題,這篇文章主要介紹了android判斷應(yīng)用程序退到后臺的方法,需要的朋友可以參考下2023-03-03實時獲取股票數(shù)據(jù)的android app應(yīng)用程序源碼分享
本文我們分享一個實時獲取股票數(shù)據(jù)的android app應(yīng)用程序源碼分享,可以作為學(xué)習(xí)使用,本文貼出部分重要代碼,需要的朋友可以參考下本文2015-09-09android仿Adapter實現(xiàn)自定義PagerAdapter方法示例
這篇文章主要給大家介紹了關(guān)于android仿Adapter實現(xiàn)自定義PagerAdapter的相關(guān)資料,文中詳細(xì)介紹了關(guān)于PagerAdapter的用法,對大家的理解和學(xué)習(xí)具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2017-11-11超精準(zhǔn)的Android手機(jī)計步器開發(fā)
這篇文章主要為大家詳細(xì)介紹了超精準(zhǔn)的Android手機(jī)計步器開發(fā)過程,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-10-10