How to get memory (RAM/ROM) consumption details in Android?

1.2k views Asked by At

I am developing an Android App, where I have to display RAM consumption by each app running on the device as a foreground and background, I have gone through multiple solutions, but they only talk about total RAM and available RAM, So my queries are

  • Is there any public API available? I didn't find much in the Android Official document.
  • Is it possible through System APP then how?
  • Is there any private API available in the framework? I can modify my framework as well, but don't know where.
1

There are 1 answers

0
atyc On

ActivityManager.getProcessMemoryInfo (int[] pids) is public API. However,

As of Android Q, for regular apps this method will only return information about the memory info for the processes running as the caller's uid; no other process memory info is available and will be zero.

You can see Settings -> System -> Developer Options (You need to enable the Developer Options) -> Memory -> Memory used by apps how to do this.

Settings app uses com.android.internal.app.procstats.ProcessStats, ActivityManager.getProcessMemoryInfo uses ProcessStats to implement.