Home  >  Q&A  >  body text

java - Android后台服务如何非root权限下获取手机当前状态信息?

我想写一个后台服务,每隔固定时间收集一次手机当前状态信息,包括内存使用情况,CPU使用情况,以及各个进程使用的资源占比。(看Linux进程也可以接受)

adb工具好像只能用来开发调试,用Linux内核的命令好像又权限不够。所以来提问。

先谢过各位了!


已经找到解决方法了,如果有其他方法欢迎大家补充!

PHPzPHPz2713 days ago991

reply all(2)I'll reply

  • 黄舟

    黄舟2017-04-18 10:55:43

    First of all, thank you for the first answer @didikee

    Following this idea, I found an Android Process class. This class seems to obtain various process information by reading the information in the proc folder. Please go to github for details.

    Another: Extended reading

    reply
    0
  • PHPz

    PHPz2017-04-18 10:55:43

    1.CPU frequency, CPU information: /proc/cpuinfo/proc/stat
    2.内存:/proc/meminfo
    3.proc/This information file in the directory is only readable, not writable.

    I took a screenshot, you can take a look for yourself: (Of course I hope you can take a look with your phone)

    Reference: http://www.cnblogs.com/brainy/archive/2012/05/30/2526752.html

    reply
    0
  • Cancelreply