i am to get the pid of the process and i want to calculate the cpu usage of the process of which i have the pid in android ndk.i am a newbie to ndk.
Anyone knows how to do that,any help will be really appreciated.
From this discussion I found that it's impossible to get that information on Android. And also I used many task managers on Android and none of them didn't provide such data (they show only memory usage).
Looks like your question is duplicate to this one.
So all you need to do is to analyze file
/proc/<pid>/stat to get CPU usage.
From source Android top.c I found how to get process usage in function
proc->delta_time * 100 / total_delta_time