Reputation:
I have an Android app with 3 activities in 1 package. I also have 1 more package(monitoring package) which has java files mainly for monitoring the performance of these 3 activities.Now I need to monitor cpu usage of my app and I need to have this cpumonitor file defined for the same in monitoring package. I am not supposed to touch the 3 activities. How do I achieve this?
I have seen various posts wherein you get the current running process from activitymanager and find cpu usage. In my case, I cant get context from these 3 activities since I am not allowed to edit them.
Upvotes: 1
Views: 3435
Reputation: 16038
Only one of those Activities will be working at any one time. So attempting to monitor all 3 is going to be fruitless.
You can however monitor a process by package name.
Run this command through Java:
ps -o com.package.name
Here is an example of running a shell command on Android.
Upvotes: 1