我正在尝试获取已用RAM的百分比,但这段代码只是给了我用MB的二手RAM。我怎么能以百分比得到它?
private void Used(){
ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
activityManager.getMemoryInfo(mi);
long availableMegs = mi.availMem / 1048576L;
long used = TotalRam() - availableMegs ;
crpv.setPercent();
crpv.setPercent(used);
tvPercent.setText(used+" MB");
}
答案 0 :(得分:0)
double percentUsed = 1.0 * used / TotalRam();