How to get total RAM size of a device?

前端 未结 5 510
囚心锁ツ
囚心锁ツ 2020-12-01 08:20

I want to get full RAM size of a device. memoryInfo.getTotalPss() returns 0. There is not function for get total RAM size in ActivityManager.MemoryInfo.

5条回答
  •  Happy的楠姐
    2020-12-01 08:47

    You can get the total RAM size by using this code:

    var activityManager = GetSystemService(Activity.ActivityService) as ActivityManager;
    var memoryInfo = new ActivityManager.MemoryInfo();
    activityManager.GetMemoryInfo(memoryInfo);
    
    var totalRam = memoryInfo.TotalMem / (1024 * 1024);

    If the device has 1GB RAM, totalRam will be 1000.

提交回复
热议问题