0

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.
ramkrishna kushwaha
  • 380
  • 1
  • 6
  • 17
  • 1
    On older Android devices you could list all processes and as far as I remember also their memory usage. On modern Android devices getting the list of processes is disabled, you only see your own app process(es). – Robert May 21 '21 at 07:25

1 Answers1

0

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.

atyc
  • 1,056
  • 7
  • 7